使用日期的Mule中的JMS消息选择器
在Mule 3.3.1中,在异步处理期间,当我的任何外部服务中断时,我都希望将消息放入具有特定下一次重试"时间戳的队列(retryQueue
).从retryQueue
处理消息的流程将根据下一次重试"时间选择消息,就像下一次重试"时间已过当前时间一样,选择要处理的消息.类似于以下链接中提到的内容.
In Mule 3.3.1, during async processing, when any of my external services are down, I would like to place the message on a queue (retryQueue
) with a particular "next retry" timestamp. The flow that processes messages from this retryQueue
selects messages based on "next retry" time as in if "next retry" time is past current time, select the message for processing. Similar to what has been mentioned in following link.
您能否提供示例代码来实现这一目标?
Could you please provide sample code to achieve this?
我尝试过:
<on-redelivery-attempts-exceeded>
<message-properties-transformer scope="outbound">
<add-message-property key="putOnQueueTime" value="#[function:datestamp:yyyy-MM-dd hh:mm:ssZ]" />
</message-properties-transformer>
<jms:outbound-endpoint ref="retryQueue"/>
</on-redelivery-attempts-exceeded>
以及接收流程
<jms:inbound-endpoint ref="retryQueue">
<!-- I have no idea how to do the selector....
I tried....<jms:selector expression="#[header:INBOUND:putOnQueueTime > ((function:now) - 30)]"/>, but obviously it doesn't work. Gives me an invalid message selector. -->
</jms:inbound-endpoint>.
另一个注意事项:如果我使用
Another note: If I set the outbound property using
<add-message-property key="putOnQueueTime" value="#[function:now]"/>,
它不会被保留为标头的一部分.这就是为什么我将其更改为:
it doesn't get carried over as part of header. That's why I changed it to:
<add-message-property key="putOnQueueTime" value="#[function:datestamp:yyyy-MM-dd hh:mm:ssZ]" />
表达式:
<jms:selector expression="#[header:INBOUND:putOnQueueTime > ((function:now) - 30)]"/>
应该评估为有效的JMS选择器,此处不是这种情况.尝试:
should evaluate to a valid JMS selector, which is not the case here. Try with:
<jms:selector expression="putOnQueueTime > #[XXX]"/>
用创建所需时间的表达式替换XXX.
replacing XXX with an expression that creates the time you want.