欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

rabbitmq配置

程序员文章站 2022-03-05 18:29:18
...
<?xml version="1.0" encoding="UTF-8"?>

<!-- 异步的线程池,线程池的最在数不能设定太小,不然<rabbit:listener/>/@RabbitListener太多的话,会出现发无法正常消费问题 -->  
<task:executor id="taskExecutor" pool-size="4-256" queue-capacity="128" />  

<!-- 定义RabbitMQ的连接工厂 -->

<rabbit:connection-factory id="connectionFactory"
	host="${rabbit.ip}" port="${rabbit.port}" username="${rabbit.username}" password="${rabbit.password}"
	virtual-host="${rabbit.vhost}" 
	publisher-confirms="true"  
    publisher-returns="true"  
    channel-cache-size="5" 
    executor="taskExecutor"/>

<!-- 定义Rabbit模板,指定连接工厂以及定义exchange -->
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory"
	exchange="orderExchange" />

<!-- MQ的管理,包括队列、交换器等 -->
<rabbit:admin connection-factory="connectionFactory" />

<!-- 定义交换器,自动声明交换机 ,durable持久化 -->
<rabbit:direct-exchange name="orderExchange" auto-declare="true" durable="true">
</rabbit:direct-exchange>

<!--发布订阅模式  -->
<!-- <rabbit:fanout-exchange name=""></rabbit:fanout-exchange> -->

<!--主题模式  -->
<!-- <rabbit:topic-exchange name=""></rabbit:topic-exchange> -->
相关标签: rabbitmq