使用日期的Mule中的JMS消息选择器 [英] JMS Message Selector in Mule using date

查看:102
本文介绍了使用日期的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.

重试JMS队列实施以交付失败一定时间间隔后的邮件

您能否提供示例代码来实现这一目标?

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.

这篇关于使用日期的Mule中的JMS消息选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆