0
我在扇出交換中使用RabbitMQ時遇到了一個問題,由於某些未知原因,它表現得像直接交換一樣。扇形交換在春季AMQP中直接交換行爲AMQP
我使用的是下面的結合和隊列配置
<bean id="testfanout"
class="com.test">
<constructor-arg name="exchange" ref="test" />
<constructor-arg name="routingKey" value="test" />
<constructor-arg name="queue" value="testQ" />
<constructor-arg name="template">
<bean class="org.springframework.amqp.rabbit.core.RabbitTemplate">
<constructor-arg ref="connectionFactory" />
</bean>
</constructor-arg>
<constructor-arg value="true"/>
</bean>
<rabbit:fanout-exchange name="test" id="test">
<rabbit:bindings>
<rabbit:binding queue="test"/>
</rabbit:bindings>
</rabbit:fanout-exchange>
現在我們有一個相同的代碼聽同一testQ在兩個不同的虛擬機,但不知何故消息使用循環算法
發送到一個VM監聽器發件人代碼
channel = ...
RabbitTemplate template = null;
if(channel != null){
template = channel.getTemplate();
if(template != null){
template.setQueue(channel.getQueue());
template.setExchange(channel.getExchange().getName());
template.convertAndSend(channel.getRoutingKey(), txtMsg);
fanout更新交換它的而不是 –
Akshat