我在春天为兔子定义了配置:
<rabbit:connection-factory id="amqpConnectionFactory" addresses="${amqp.host}:${amqp.port}"
thread-factory="rabbitThreadFactory"
cache-mode="CHANNEL"
channel-cache-size="25"
username="${amqp.user}"
password="${amqp.pass}"
virtual-host="${amqp.vhost}"/>
<rabbit:admin connection-factory="amqpConnectionFactory" id="rabbitAdmin"/>
<rabbit:topic-exchange id="motoTopicExchange" name="moto.ex.topic" >
<rabbit:bindings>
<rabbit:binding pattern="moto.*.speed" queue="motoQueue8"/>
<rabbit:binding pattern="moto.*.tour" queue="motoQueue9"/>
<rabbit:binding pattern="moto.*.naked" queue="motoQueue10"/>
</rabbit:bindings>
</rabbit:topic-exchange>
<rabbit:queue id="motoQueue8" name="moto.queue.8"/>
<rabbit:queue id="motoQueue9" name="moto.queue.9"/>
<rabbit:queue id="motoQueue10" name="moto.queue.10"/>
<rabbit:template id="rabbitTemplate"
connection-factory="amqpConnectionFactory"
retry-template="retryTemplate"
message-converter="rabbitJsonConverter"/>
<bean id="rabbitJsonConverter" class="org.springframework.amqp.support.converter.Jackson2JsonMessageConverter"/>
<rabbit:listener-container connection-factory="amqpConnectionFactory" message-converter="rabbitJsonConverter"
max-concurrency="10" acknowledge="auto">
<rabbit:listener ref="amqpService8" method="handleSimple" queues="motoQueue8"/>
<rabbit:listener ref="amqpService9" method="handleSimple" queues="motoQueue9"/>
<rabbit:listener ref="amqpService10" method="handleSimple" queues="motoQueue10"/>
</rabbit:listener-container>
侦听器中的handleSimple方法使用对象,例如Motorcycle(发送思想amqp时也有json转换)。
我不想配置侦听器思想注释。
由于
答案 0 :(得分:1)
对手动acks有什么期望?需要它们是很不寻常的;容器会照顾你。
要使用手动确认,您需要ChannelAwareMessageListener
实施。
您还必须自己调用消息转换器。