1

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.

1 Answer 1

2

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.

4
  • I enjoy the publish facility, and would prefer to not have to specify the endpoints I am sending to. I will look at transient queues.
    – spaceman
    Commented Jun 27, 2013 at 12:08
  • 1
    Transient queues only work with the RabbitMQ transport. The endpoints need the queues so they can some place to receive subscription data.
    – Travis
    Commented Jun 27, 2013 at 12:15
  • 1
    What you could do is just have a single endpoint that the web farm .Send()s to and then that one publishes. Like msmq://localhost/bridge_me, have a service listening on that queue that does the publish to another process (or processes).
    – Travis
    Commented Jun 27, 2013 at 12:16
  • Thats what I ended up doing.
    – spaceman
    Commented Jun 27, 2013 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.