Vij*_*van 4 spring-integration spring-amqp
1)服务器向客户端发送消息.
2)入站通道适配器配置为等待来自用户的"手动"确认模式操作
3)"TaskBundlereceiver"bean正在实现"ChannelAwareMessageListener",在实现方法中,我正在执行消息确认.
我没有看到"TaskBundlereceiver"被执行.我错过了什么吗?
以下是我所解释的步骤的配置细节.
感谢您的意见.
@Override
public void onMessage(org.springframework.amqp.core.Message message, Channel channel) throws Exception
{
logger.debug("In onMessage method of the channel aware listener. message =["+message.getBody().toString()+"]");
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
}
Run Code Online (Sandbox Code Playgroud)
XML配置:
<!-- Channel that receives the task bundle from the server for execution -->
<int:channel id="fromKServerChannel"/>
<int-amqp:inbound-channel-adapter id="taskBundleReceiverAdapter"
channel="fromKServerChannel"
error-channel="taskBundleErrorChannel"
acknowledge-mode="MANUAL"
expose-listener-channel="true"
queue-names="kanga_task_queue"
connection-factory="connectionFactory"
concurrent-consumers="20"/>
<int:chain input-channel="fromKServerChannel" output-channel="nullChannel">
<int:service-activator ref="taskBundleReceiver" method="onMessage"/>
<int:service-activator ref="taskBundleExecutor" method="executeBundle"/>
</int:chain>
Run Code Online (Sandbox Code Playgroud)
它不起作用; 监听器是适配器,而不是通过服务激活器调用的服务.适配器当前不支持将通道传递给客户端以进行手动确认.expose-listener-channel属性用于使用事务时,因此向下堆栈的兔子模板可以参与事务.
你为什么想要手动的acks?AUTO(默认值)表示当线程正常返回时,容器将自动完成ack; 如果您的服务抛出异常,则消息将被删除.
那么,这就是如何控制ack.
如果你真的想使用MANUAL acks,你必须使用a <rabbit:listener-container/>来直接调用你的taskBundleReceiver.然后,它可以使用消息传递网关向执行程序发送消息.
| 归档时间: |
|
| 查看次数: |
7399 次 |
| 最近记录: |