NServiceBus.RabbitMQ - How does connection management work and differ between messagepump, publish, and sendonly endpoints?

We are currently using the RabbitMQ Transport with NServicebus. When i navigate to the connections tab from the rabbitmq ui i see differently named connections. They follow the following structure

<endpoint_name> Publish
<endpoint_name> MessagePump

I notice some of them seem to be persist and have a “Connected at” for more than 8 days ( so the connection was created and reused for quite a while ) and some of them appear to have a “Connected at” from just a few seconds ago ( so it’s a new connection ). I would like to understand the difference between <endpoint_name> Publish and <endpoint_name> MessagePump along with information on how long they “should” be keeping a connection open with rabbit or if we have something misconfigured causing connections to be constantly opened and closed which works but is not ideal resource wise.

Hi @jtim08515 ,

Each endpoint will will usually have a Publish and a MessagePump connection open, unless it’s a send-only endpoint, in which case only a Publish connection would be required. These two connections are used by different parts of NServiceBus:

  • The MessagePump connection is a connection used to consume messages from queues to be processed by NServiceBus
  • The Publish connection is used to publish/send messages to exchanges (typically via NServiceBus Send or Publish operations).

The connections should ideally remain open as creating connections can be resource-intensive and NServiceBus tries to avoid that, so long-running connections are expected/desired (compared to short-lived channels). There might be many reasons a connection might be closed though, e.g. certain type of exceptions and network issues will fail the whole connection, not just a channel, and require the connection to be recreated. Wenn starting endpoint, there might also be short-lived administration connections too. Without further details, I can’t tell you whether a “recently recreated connection” is an indication of a misconfiguration or not. Generally speaking, if you don’t see new connections being created all the time, it’s probably not a big issue. Checking the RabbitMQ logs for details on the connection would be a good start for further investigation. NServiceBus also logs reconnects (at Info level).

Some of the connection management in the RabbitMQ transport for NServiceBus has also been improved over time, so I’d make sure that you’re on the latest version of the NServiceBus.RabbitMQ package.