"
<code class=""language-xml""><?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-1.7.xsd">
<!-- 连接配置 -->
<rabbit:connection-factory id="connectionFactory"
host="${rabbitmq.host}"
username="${rabbitmq.username}"
password="${rabbitmq.password}"
port="${rabbitmq.port}"
virtual-host="${rabbitmq.vhost}"/>
<rabbit:admin connection-factory="connectionFactory"/>
<!-- spring template声明-->
<rabbit:template id="amqpTemplate"
connection-factory="connectionFactory"
message-converter="jsonMessageConverter"/>
<!-- 消息对象json转换类 -->
<bean id="jsonMessageConverter"
class="org.springframework.amqp.support.converter.Jackson2JsonMessageConverter"/>
<!--延迟队列:没人消费-->
<rabbit:queue name="delayQueue" durable="true">
<rabbit:queue-arguments>
<entry key="x-dead-letter-exchange" value="directExchange"/>
<entry key="x-dead-letter-routing-key" value="taskRoutingKey"/>
</rabbit:queue-arguments>
</rabbit:queue>
<!--死信队列:过期的消息会被路由到该队列,然后被消费-->
<rabbit:queue name="taskQueue" durable="true" />
<rabbit:direct-exchange name="directExchange" durable="true">
<rabbit:bindings>
<rabbit:binding queue="delayQueue" key="delayRoutingKey"/>
<rabbit:binding queue="taskQueue" key="taskRoutingKey"/>
</rabbit:bindings>
</rabbit:direct-exchange>
<bean id="messageReceiver" class="com.huweitech.service.rabbitmq.impl.MQConsumerImpl"/>
<rabbit:listener-container connection-factory="connectionFactory">
<rabbit:listener ref="messageReceiver" queues="taskQueue"/>
</rabbit:listener-container>
</beans>
这个是我的配置,我在rabbit控制台上看到消息发出去了,但是感觉像一发出去就被丢弃了,求各位指点。
"版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。