我为入站通道创建了bean,将acknowledge属性设置为manual,并使用chain方法发布输出消息,
<int-amqp:inbound-channel-adapter channel="InputChannel"
queue-names="Input" connection-factory="connectionFactory" concurrent-consumers="1" message-converter="Converter"
acknowledge-mode="MANUAL" prefetch-count="5"/>
<int:chain input-channel="InputChannel" output-channel="OutputChannel">
<int:transformer method = "transform" >
<bean class="com.sampleconverter" />
</int:transformer>
<int:service-activator method="transform">
<bean class="com.Transformer" />
</int:service-activator>
<int:object-to-string-transformer />
</int:chain>
请您帮我确认使用手动确认模式
处理的消息提前致谢。
答案 0 :(得分:0)
Reference Manual有关于此事的专门段落:
将模式设置为
MANUAL
允许用户代码在处理期间的某个其他位置处理消息。为了支持这一点,使用此模式,端点分别在amqp_channel和amqp_deliveryTag标头中提供Channel和deliveryTag。
@ServiceActivator(inputChannel = "foo", outputChannel = "bar")
public Object handle(@Payload String payload, @Header(AmqpHeaders.CHANNEL) Channel channel,
@Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag) throws Exception {
// Do some processing
if (allOK) {
channel.basicAck(deliveryTag, false);
// perhaps do some more processing
}
else {
channel.basicNack(deliveryTag, false, true);
}
return someResultForDownStreamProcessing;
}