Announcement Announcement Module
Collapse
No announcement yet.
Sharing a RabbitTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sharing a RabbitTemplate

    Hi All,

    I am putting together a relatively simple demo of Spring AMQP and RabbitMQ.

    After some initialization code has finished, I was going to create several producer threads. At first I was going to let each producer thread instantiate its own RabbitTemplate. But then I thought that I might simply pass to the thread's constructor the template I created in the initialization code.

    Thus, each producer thread and the "main" thread code that comes after init would all be using same template.

    Is this OK, or are there "issues" with such an approach?

    More generally, I have the same question about sharing objects like RabbitAdmin and Exchange.

    Thanks for your help.

    -Paul

  • #2
    As with most Spring strategies RabbitTemplate is thread safe after configuration (so fine to share). Ditto the other things - just don't re-configure them once you start using them, which normally means you are fine if you stick to coding to the interfaces.

    Comment


    • #3
      Thank you, Dave.

      -Paul

      Comment

      Working...
      X