從生產者我必須發送消息到RabbitMQ Exchange。這個消息將包含特定的屬性,例如隊列名稱,根據這個屬性,我必須動態地決定發送這個消息的隊列。[隊列綁定從交換,發送這個特定消息]。使用彈簧集成在Exchange中動態選擇RabbitMq隊列
有沒有什麼方法可以截獲到達RabbitMQ Exchange的消息,使用spring集成,目前我有以下spring集成配置文件。
我不知道如何創建一個bean來獲取Exchange消息並將消息路由到smsQueue,emailQueue等隊列。
感謝您的建議和答覆。
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration/amqp
http://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd
">
<context:annotation-config></context:annotation-config>
<context:component-scan base-package="com.rabbit"></context:component-scan>
<rabbit:connection-factory id="connectionFactory"
host="localhost" username="guest" password="guest" />
<rabbit:admin connection-factory="connectionFactory" />
<rabbit:template id="exchnageTemplate"
connection-factory="connectionFactory" exchange="COMMUNICATION-EXCHANGE" />
<rabbit:queue id="smsQueue" auto-delete="true" durable="false" />
<rabbit:queue id="emailQueue" auto-delete="true" durable="false" />
<rabbit:queue id="dvbQueue" auto-delete="true" durable="false" />
<rabbit:queue id="pbxQueue" auto-delete="true" durable="false" />
<rabbit:queue id="medsensorQueue" auto-delete="true"
durable="false" />
<int:gateway id="gateway" service-interface="com.rabbit.mq.ProducerGatewayInterface"
default-request-channel="producerChannel" />
<int:channel id="producerChannel" />
<int:channel id="errorChannel" />
<bean id="communicationInterface" class="com.rabbit.mq.CommunicationInterface" />
<amqp:outbound-channel-adapter channel="producerChannel"
amqp-template="exchnageTemplate" exchange-name="COMMUNICATION-EXCHANGE">
<int:service-activator input-channel="input"
ref="communicationInterface" method="optimalRoutingOfMessage" />
</amqp:outbound-channel-adapter>
嗨,非常感謝您的回答。測試後我會接受它。 - Muthuvel –