Question

I have been running masstransit / msmq for a while now with no problems, using it to send a message from an asp.net mvc app to a windows service.

My global asax contains the following in the OnApplicationStarted event :

 MessageBus = ServiceBusFactory.New(sbc =>
            {
                sbc.UseMsmq();
                sbc.VerifyMsmqConfiguration();
                sbc.UseMulticastSubscriptionClient();
                sbc.ReceiveFrom("msmq://localhost/websiteQueue");
                sbc.Subscribe(subs =>
                {

                });
            });

Please note, this bus is configured to only send messages, it doesn't recieve anything. This is important.

Recently we have implemented a web garden in IIS. This is when you up the number of worker processes to more than 1. It gains you some performance by spinning up multiple copies of the site. And this is the problem.

Masstransit only allows a single instance of each queue, and ever since we've created our web garden, the messaging has stopped working intermittently. I am guessing it sometimes works because I am lucky enough to hit the instance of the site with active access to the queue.

But like I mentioned before, the queue is useless anyway, I never use it to receive anything. I was wondering if there was some way to convert this to a send only bus, where I publish messages, but never receive them?

For a short period I added a Guid.NewGuid() onto the end of the queue name, and it did start working. The only problem is it created 10 new queues every time we restart the site. This is obviously not really a permanent solution.

Was it helpful?

Solution

The advantage of having a bus is that your sender can be ignorant of the recipients and simply use bus.Publish().

If that's a desired characteristic you may want to look into setting up transient queues (might be available with RabbitMQ transport only though).

If knowing your consumers is not a big deal then you definitely can make do w/o the bus, just use EndpointCacheFactory (make sure it's a singleton):

var endpointCache = EndpointCacheFactory
                .New(x => x.UseMsmq())

and obtain your IEndpoint:

var targetEndpoint = endpointCache.GetEndpoint(new Uri(targetAddress)))

then use .Send() on it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top