I'm using MassTransit 3 to publish messages to RabbitMQ from a web server. My IBusControl instance is created manually but it's wrapped in a service. The service is injected using StrctureMap 2 and is request-scoped. IBusControl instance is disposed along with the service. I chose this approach mainly because I started noticing a lot of abandoned connections in the management console when I wasn't manually disposing of the IBusControl instance.
However, I am worried about the fact that it needs to open and close a connection to RabbitMQ on each request, especially in a high load environment (chat app) - that can't be "cheap." An alternative would be to make it a singleton, but I am wary of concurrency issues due to a large number of requests.
I am wondering whether there is a best practice in regards of lifecycle management for IBusControl instance in a web scenario. If not, are there any other alternatives that I missed?
EDIT: After doing more research and with the help of this particular answer (and the corresponding page in RabbitMQ docs), it appears that the best approach is to use a single connection for the lifetime of the app but create channels per thread, which would equate to a channel per web request.
Now the question becomes, when doing a Publish via MassTransit, does it use a new channel every time while maintaining the same connection?