Using MassTransit as a Consumer in ASP.NET MVC

1,418 views
Skip to first unread message

jon333

unread,
Feb 19, 2014, 11:56:50 AM2/19/14
to masstrans...@googlegroups.com
We have a kind of strange use case where we have an MVC app that wants to consume messages from MassTransit (backed by RabbitMQ) and we're wondering if this is supported.  We usually have Windows Services that do not have the the AppPool recycle issues that ASP.NET may occassionally encounter and we're just wondering if there are any concerns over setting up a consumer in ASP.NET MVC if there is any advice.

Thanks,

Mark Huber

unread,
Feb 19, 2014, 2:01:29 PM2/19/14
to masstrans...@googlegroups.com
We do this today to signal cache clears to our web servers. Works great.

Mark Huber


On Wed, Feb 19, 2014 at 10:56 AM, jon333 <jonath...@gmail.com> wrote:
We have a kind of strange use case where we have an MVC app that wants to consume messages from MassTransit (backed by RabbitMQ) and we're wondering if this is supported.  We usually have Windows Services that do not have the the AppPool recycle issues that ASP.NET may occassionally encounter and we're just wondering if there are any concerns over setting up a consumer in ASP.NET MVC if there is any advice.

Thanks,

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/3f5e2bfb-320a-4192-846f-861d5892b651%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

jonathan{GILL}

unread,
Feb 19, 2014, 2:49:58 PM2/19/14
to masstrans...@googlegroups.com
Hi Mark,
This is exactly the purpose we are wanting to use this for.  Did you have to do anything special when registering MassTransit (we're using Autofac)?


--
You received this message because you are subscribed to a topic in the Google Groups "masstransit-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/masstransit-discuss/wDOu3xmTqbc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to masstransit-dis...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Mark Huber

unread,
Feb 19, 2014, 3:37:59 PM2/19/14
to masstrans...@googlegroups.com
No, we're not using an IoC container so our bus is initiated in Global.asax.cs

It works pretty much as you'd suspect, we manage the bus as a singleton, make sure you're not setting it up and tearing it down every request or something like that. We did that in another application, it's a sure fire way to create a memory leak and crash a rabbitmq server.



Chris Patterson

unread,
Feb 19, 2014, 11:29:48 PM2/19/14
to masstrans...@googlegroups.com
As mentioned above, it works fine. We use it as well to clear caches. :)

Just make sure you dispose the bus on Application_End (or your container, if you have one containing the bus).

We also with RabbitMQ use a temporary queue/exchange (rabbitmq://server/*?temporary=true) -- this will create an auto-delete queue/exchange that is discarded once the bus is disposed (and the RabbitMQ connection is closed).



Reply all
Reply to author
Forward
0 new messages