SendOnly. Avoid constant connectivity

I am using NServicebus 7x with RabbitMQ transport.

My service is a SendOnly endpoint, and will rarely send messages. Let´s say once a day.

Is there some best practice using a Endpoint, that will connect to RMQ when in use and close the connection after an idle period? (the connection is reused if sending more messages within e.g. 5 minutes)

I don’t see a specific reason to teardown a connection but if you really want to you then might just want to create/teardown an endpoint instance for that task that only sends a single message per day.

Maybe an even better approach would be to not have the process running 24x7 then too when you are concerned about idle resources?

NServiceBus itself doesn’t have any logic to teardown resources for send-only instances based on Idle time.

Are you running into any issues because of the publish connection to remain open?

I haven’t really any issues, I am just planning ahead. :slight_smile: I was just thinking if I had a micro service, with a endpoint used for batch processing at night, then I don’t want the IT operations to worry if connectivity is lost when not in use. It is SendOnly, so I kind of compare it to a DB connection. I understand the only approach is to open and shut it down on demand.

It is an interesting idea but if connections would be closed when idle then reconnecting would introduce latency. In general it is expected that messages will be dispatched quickly.

I’ve capture this in the following issue:

Please add any comments to that issue that could help us better understand the need for this as currently it is unlikely that this would get prioritized from all enhancements we could add.