Subscriptions with MakeInstanceUniquelyAddressable

I wish to support the following scenario.
Multiple Hosts with a single endpoint instance all using the competing consumer pattern to process messages from QueueA.
Additionally each Host should be able to subscribe to an event. In this scenario we wish to update an in memory cache via the event message. When the Event fires ALL Hosts should receive a copy of the event message.
I have tried using the MakeInstanceUniquelyAddressable property on EndpointConfiguration, this results in an additional queue being created.
However when the endpoint subscribes to the event it uses the LocalAddress
[From MessageDrivenSubscriptions.cs ]

        if (canReceive)
            var subscriberAddress = context.Receiving.LocalAddress;
            var subscriptionRouter = new SubscriptionRouter(publishers, endpointInstances, i => transportInfrastructure.ToTransportAddress(LogicalAddress.CreateRemoteAddress(i)));

            context.Pipeline.Register(b => new MessageDrivenSubscribeTerminator(subscriptionRouter, subscriberAddress, context.Settings.EndpointName(), b.Build<IDispatchMessages>()), "Sends subscription requests when message driven subscriptions is in use");
            context.Pipeline.Register(b => new MessageDrivenUnsubscribeTerminator(subscriptionRouter, subscriberAddress, context.Settings.EndpointName(), b.Build<IDispatchMessages>()), "Sends requests to unsubscribe when message driven subscriptions is in use");

If it was possible to use context.Receiving.InstanceSpecificQueue then I believe this would all work as I wanted. However currently the event message is only processed by one of my instances.

Is there a way to override this feature (I’d rather not try that) or is there another suggested approach?

Hi James

Would this help?

and see the sample

Please notice the warning

Asynchronous messaging is not an optimal solution for data distribution scenarios. It is usually better to use a dedicated data distribution technology, such as a distributed cache or distributed configuration service. This sample is meant to demonstrate the flexibility of the NServiceBus routing engine.

Another option would be to use a command and send that command to all uniquely addressable instances directly with something like

   var options = new SendOptions();
   var message = new InvalidateCache();
   await endpoint.Send(message, options)

Hope that helps


Thanks for the suggestions.