Nservicebus: Message Driven Subscriptions requires Subscriber to have persistence?

Created on 15 Feb 2018  路  10Comments  路  Source: Particular/NServiceBus

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);```

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" ?

All 10 comments

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

There seems to be 2 parts to this:

  1. Decide if we should require storage for endpoints that are just subscribing. Atm moment there is no way to know if an endpoint is "subscriber only" so it would have to be a config option?
  2. Make sure that we throw a useful exception if users disable MessageDrivenSubscriptions on transports that require it

Did 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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SimonCropp picture SimonCropp  路  6Comments

timbussmann picture timbussmann  路  10Comments

timbussmann picture timbussmann  路  7Comments

andreasohlund picture andreasohlund  路  9Comments

SeanFeldman picture SeanFeldman  路  6Comments