我正在使用Spring Integration 4.1.6 jms消息流,它有两个队列,主队列和异常队列。从主队列中读取消息,进行处理,如果处理不成功,则将消息推送到异常队列。我有一个轮询器,它从异常队列中读取消息,然后放回到主队列中。我需要这个过程有条件的,如果消息是从异常队列移动到主队列,比方说,3次,然后忽略消息。为此,我计划将属性添加到消息头'Retry_Count‘中,并在将消息从错误队列推送到主队列或丢弃消息时进行检查。1.如何检查'Retry_Count‘属性是否在消息上? 2.如果'Retry_Count’属性不在消息上,则添加初始计数,例如1并路由到主队列3.如果'Retry_Count‘属性在消息上,则检查重试计数是否小于或等于最大重试次数,4.如果'Retry_Count’属性值小于最大计数,则递增计数并路由到主队列。5.如果'Retry_Count‘属性值等于最大计数,则路由到丢弃队列。
注意轮询器配置是通过从异常队列读取消息并路由到主队列来工作的。
发布于 2016-04-22 21:44:28
通过一些阅读和配置,我能够解决我所面临的问题。我使用sprint集成对象来设置重试属性,而不是JMS消息。以下是配置
<si-jms:inbound-channel-adapter
channel="BackoutQueueChannel" connection-factory="queueConnectionFactory"
destination="RegistrationBackoutQueue">
<si:poller cron="0 0/2 * * * *"
max-messages-per-poll="2">
<si:advice-chain>
<ref bean="PollSkipAdvice"/>
</si:advice-chain>
</si:poller>
</si-jms:inbound-channel-adapter>
<si:chain id="processBackoutQueue" input-channel="BackoutQueueChannel" output-channel="RecipientChannel" >
<si:header-enricher>
<si:header name="Event_Retry_Count" expression="headers.get('Event_Retry_Count') == null ? 2 : headers.get('Event_Retry_Count')+1" overwrite="true"/>
</si:header-enricher>
<si:filter id="checkEventEligibleForRetry" expression="@RegistrationEventPoller.isEventEligibleForRetry(payload, headers.get('Event_Retry_Count'))" discard-channel="poisonChannel"/>
</si:chain>
https://stackoverflow.com/questions/36602682
复制相似问题