Bootstrap

RabbitMQ项目使用配置

生产者配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="
            http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/rabbit
          http://www.springframework.org/schema/rabbit/spring-rabbit.xsd">


   <rabbit:connection-factory id="connectionFactory"
host="10.153.25.15" username="insurance" password="insurance" port="5672" />

   <rabbit:admin connection-factory="connectionFactory" />

   <rabbit:queue id="queue_insurance" durable="true" auto-delete="false"
exclusive="false" name="queue_insurance">正常队列当中指向死信
      <rabbit:queue-arguments>
         <entry key="x-message-ttl">设置超时
            <value type="java.lang.Long">30000</value>
         </entry>
         <entry key="x-dead-letter-exchange">指定交换机
            <value type="java.lang.String">alter</value>
         </entry>
      </rabbit:queue-arguments>
   </rabbit:queue>

   <rabbit:queue id="alter_queue" durable="true" auto-delete="false" exclusive="false" name="alter_queue"/>死信队列

   <rabbit:direct-exchange name="alter"
durable="true" auto-delete="false" id="alter">死信交换机
      <rabbit:bindings>
         <rabbit:binding queue="alter_queue" key="queue_key_insurance"/>
      </rabbit:bindings>
   </rabbit:direct-exchange>
   <rabbit:direct-exchange name="exchange_insurance"
durable="true" auto-delete="false" id="exchange_insurance">正常交换机
      <rabbit:bindings>
         <rabbit:binding queue="queue_insurance" key="queue_key_insurance" />
      </rabbit:bindings>
   </rabbit:direct-exchange>

<!-- (5)客户端投递消息到exchange。 -->
<rabbit:template id="amqpTemplate" exchange="exchange_insurance"
connection-factory="connectionFactory" />
</beans>
;