Java 如何在Spring集成中向exchange动态添加队列
我在integrationcontext.xml中进行了以下交换Java 如何在Spring集成中向exchange动态添加队列,java,spring,spring-boot,spring-integration,spring-integration-amqp,Java,Spring,Spring Boot,Spring Integration,Spring Integration Amqp,我在integrationcontext.xml中进行了以下交换 <!-- rabbit exchanges, queues, and bindings used by this app --> <rabbit:topic-exchange name="newPaymentEventsExchange" auto-delete="false" durable="true"> <rabbit:bindings> </rabbit:bind
<!-- rabbit exchanges, queues, and bindings used by this app -->
<rabbit:topic-exchange name="newPaymentEventsExchange" auto-delete="false" durable="true">
<rabbit:bindings>
</rabbit:bindings>
</rabbit:topic-exchange>
使用
AmqpAdmin
执行此类操作:
/**
* Declare the given queue.
* @param queue the queue to declare.
* @return the name of the queue.
*/
String declareQueue(Queue queue);
/**
* Declare a binding of a queue to an exchange.
* @param binding a description of the binding to declare.
*/
void declareBinding(Binding binding);
您可以考虑使用<代码> QueueBuilder < /C>和<代码> BindingBuilder < /> >以方便:
QueueBuilder.nonDurable("foo")
.autoDelete()
.exclusive()
.withArgument("foo", "bar")
.build()
...
BindingBuilder.bind(
marketDataQueue()).to(marketDataExchange()).with(marketDataRoutingKey)
QueueBuilder.nonDurable("foo")
.autoDelete()
.exclusive()
.withArgument("foo", "bar")
.build()
...
BindingBuilder.bind(
marketDataQueue()).to(marketDataExchange()).with(marketDataRoutingKey)