1

When using RabbitMQ and its channel model, how often am I supposed to close channels?

For example is it best practise to

  • Close the channel at the end of the method it got opened?
  • Reuse the channel globally between different methods?

On a sidenote: I am using RabbitMQ in Clojure through the Langohr Library and thus prefer to not have any global state, which prompts me to declare channels at the start of relevant messages and then to close them at the end again. I am just not sure if this is intended.

WeGi
  • 1,908
  • 1
  • 21
  • 33

1 Answers1

2

If it's easiest to open channel, execute a method, then close it, by all means do so. If your performance requirements are such that this causes too much slowdown, then start investigating channel re-use.

Opening / closing channels is not nearly as resource intensive as opening and closing connections.


NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Luke Bakken
  • 8,993
  • 2
  • 20
  • 33