rabbitMQ-Spring配置文件
其他
2019-04-09 15:01:03
阅读次数: 0
<beans xmlns="http://www.springframework.org/schems/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rabbit="http://www.springframework.orh/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/rabbit
http://www.springframework.org/schema/rabbit/spring-rabbit-1.7.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
<!-- 定义rabbitMQ连接工厂 -->
<rabbit:connection-factory id="connectionFactory"
host="127.0.0.1" port="5672"
username="guest" password="guest"
virtual-host="/vhost"/>
<!-- 定义rabbit模板 指定连接工厂以及定义exchange -->
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" exchange="fanoutExchange"/>
<!-- MQ的管理 包括队列 交换机声明 -->
<rabbit:admin connection-factory="connectionFactory"/>
<!-- 定义队列 自动声明 持久化-->
<rabbit:queue name="myQueue" auto-declare="true" durable="true"/>
<!-- 定义交换器 自动声明 -->
<rabbit:fanout-exchange name="fanoutExchange" auto-declare="true">
<rabbit:bindings>
<rabbit:bing queue="myQueue"/>
</rabbit:bindings>
</rabbit:fanout-exchange>
<!-- 队列监听 -->
<rabbit:listener-container connection-factory="connectionFactory">
<rabbit:listener ref="foo" method="listen" queue-names="myQueue"/>
</rabbit:listener-container>
<!-- 消费者 -->
<bean id="foo" class="com.mmr.rabbitmq.spring.Consumer"/>
</beans>
欢迎加入软件开发QQ群675997991,喜欢开发热爱技术的小伙伴一起交流探讨!一起分享快乐!
转载自blog.csdn.net/qq_34405062/article/details/81229295