Currently using NSB 7 beta 12 and SQL Transport and Persistence betas. We think we've found an issue with subscriptions
We have a subscriber with no persistence. This requires the message driven subscription feature to be turned off in the endpoint config. (See endpoint config below)
With this feature off the RegisterPublisher call in the subscriber doesn't send a message to the publisher.
And there is no indication that the subscription has to be done manually.
Seems odd that persistence is required by the subscriber for this to work, given that the publisher does the persistence of the subscription. Is this correct or a bug?
In our case this resulted in message loss, as we removed the persistence prior to deployment to a higher. In the lower environment the subscriber previously had persistence so we didn't pick up the fact the subscription was not registered.
```
var endpointConfiguration = new EndpointConfiguration(endpointName);
endpointConfiguration.SendFailedMessagesTo("error");
var serialization = endpointConfiguration.UseSerialization
serialization.Settings(jsonSerializerSettings);
endpointConfiguration.DefineCriticalErrorAction(OnCriticalError);
endpointConfiguration.DisableFeature
endpointConfiguration.DisableFeature
var transport = endpointConfiguration.UseTransport
transport.ConnectionString(connectionString);
transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
transport.TimeToWaitBeforeTriggeringCircuitBreaker(TimeSpan.FromMinutes(10));
var routing = transport.Routing();
routing.RegisterPublisher(typeof(BriefDivisionChanged).Assembly, "BriefEventPublisher");
routing.RouteToEndpoint(typeof(SendEmail).Assembly, "Notifications");
endpoint = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false);```
RegisterPublisher doesn't send subscription messages, it just adds the specified endpoint to a collection to be used later.
The actual subscription messages are being sent by the AutoSubscribe feature. However, because you've disabled the MessageDrivenSubscriptions feature, that means the subscribe/unsubscribe terminators aren't registered on the pipeline, so nothing is happening when AutoSubscribe attempts to subscribe to the event.
I would suspect that even attempting to manually subscribe would fail when MessageDrivenSubscriptions is disabled.
There currently isn't a way to both disable MessageDrivenSubscriptions and still have subscription messages be sent.
@danielmarbach How hard do you think it would be to add a check during pipeline creation to ensure a pipeline ends with a terminator?
Thanks, As a workaround we'll add InMemory persistence to the subscribers so we can turn on MessageDrivenSubscriptions
@bording we would probably need to verify it in https://github.com/Particular/NServiceBus/blob/develop/src/NServiceBus.Core/Pipeline/PipelineModelBuilder.cs#L19 and add a proper test to this https://raw.githubusercontent.com/Particular/NServiceBus/develop/src/NServiceBus.Core.Tests/Pipeline/PipelineModelBuilderTests.cs
There seems to be 2 parts to this:
MessageDrivenSubscriptions on transports that require itDid I get it right?
@gbiellem are you saying that this worked in v6?
would it be an option to just configure InMemoryPersistence in case you know that you won't receive any subscriptions on this endpoint?
AFAIK nothing changed related to this in v7, so v6 should have the same behavior.
@andreasohlund yep that sounds right.
@timbussmann - Great minds. If you look a few message back you'll see I said we'll use InMemoryPersistence as a workaround
@gbiellem @Particular/nservicebus-maintainers how about we raise a new issue dealing with
"Disabling MessageDrivenSubscriptions on transports with no native pubsub causes subscription requests to silently fail" ?
Raised https://github.com/Particular/NServiceBus/issues/5120 to track "Disabling MessageDrivenSubscriptions on transports with no native pubsub causes subscription requests to silently fail"
Closing this
Most helpful comment
@gbiellem @Particular/nservicebus-maintainers how about we raise a new issue dealing with
"Disabling MessageDrivenSubscriptions on transports with no native pubsub causes subscription requests to silently fail" ?