Spring RabbitTemplate - How to create queues automatically upon send

后端 未结 2 397
刺人心
刺人心 2021-01-18 03:15

I am using RabbitMQ together with Spring\'s RabbitTemplate.

When sending messages to queues using the template send methods, I want the queue to automatically be cre

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-18 04:05

    Yes, you can use a RabbitAdmin and admin.getQueueProperties() to see if the queue exists and admin.declareQueue(new Queue(...)) to add a queue. You should probably keep track of which one's you've already checked/created in order to avoid the overhead on every send.

    You can also add exchanges and bind queues to them with the admin.

提交回复
热议问题