Mule ESB:出站属性为日期,但入站属性为空

Mule ESB:出站属性为日期,但入站属性为空,mule,Mule,我正在使用Objectstore模块跟踪文档的修订号和时间戳。下面的子流将出站属性“thisTimestamp”设置为新日期() 然后使用ActiveMQ将消息发送到JMS出站端点,并由另一个ActiveMQ JMS入站端点接收。记录器显示已在出站作用域上设置属性,thisTimestamp=Thu Jan 02 15:04:08 EST 2014,但相应的入站作用域属性为空。有什么好处 编辑以添加:有趣的是,当我检查AMQ队列上的消息时,thisTimestamp属性也没有设置。如果要通过

我正在使用Objectstore模块跟踪文档的修订号和时间戳。下面的子流将出站属性“thisTimestamp”设置为新日期()


然后使用ActiveMQ将消息发送到JMS出站端点,并由另一个ActiveMQ JMS入站端点接收。记录器显示已在出站作用域上设置属性,
thisTimestamp=Thu Jan 02 15:04:08 EST 2014
,但相应的入站作用域属性为空。有什么好处


编辑以添加:有趣的是,当我检查AMQ队列上的消息时,
thisTimestamp
属性也没有设置。

如果要通过
路径,那么这是预期的行为,因为属性不会传播到enricher范围之外:

实现扩展资源的消息处理器是 使用当前消息的副本以及任何流或 存在的会话变量。调用此消息 处理器是在主流程的单独上下文中完成的,因此 修改邮件(及其属性和附件)或 流或会话变量不会反映在 enricher已配置


复制我在Mule社区论坛上收到的来自用户John Stegeman的正确答案:

刚看了一下源代码:

看来它应该会起作用。我使用了一个使用ActiveMQ队列的流,并进行了尝试。日期没有出现。如果我输入字符串()它的日期

看看JMS规范就可以解开这个谜团:

告诉我们:

属性值可以是布尔值、字节值、短值、int值、长值、浮点值、双精度值和字符串

这就是原因。您不能使用日期。

都包含相同的Enricher,它们都针对两个出站属性
thisRevision
thisTimestamp
。“消息的充实(或修改)方式是通过显式配置充实资源的结果与使用Mule表达式的消息之间的映射(源->目标)。Mule表达式用于选择要从充实资源(源)返回的结果中提取的值并定义将此值插入消息的位置(目标)。”
<sub-flow name="set_revision_and_timestamp" doc:name="set_revision_and_timestamp">
    <enricher doc:name="Message Enricher" target="#[flowVars['OSrecordExists']]" >
        <objectstore:contains config-ref="My_Objectstore" key="#[message.outboundProperties['dbDatabase'] + message.outboundProperties['dbCollection']]" doc:name="Contains"/>
    </enricher>     
    <choice doc:name="Choice" >
        <when expression="#[flowVars['OSrecordExists'] == false]">
        <!-- create a new record with rev num 1 -->
            <objectstore:store config-ref="My_Objectstore" key="#[message.outboundProperties['dbDatabase'] + message.outboundProperties['dbCollection']]" value-ref="#[['revision' : 1, 'timestamp' : new Date()]]" doc:name="Store"/>
        <enricher doc:name="Message Enricher">
            <objectstore:retrieve config-ref="My_Objectstore" key="#[message.outboundProperties['dbDatabase'] + message.outboundProperties['dbCollection']]" doc:name="Retrieve"/>
            <enrich target="#[message.outboundProperties['thisRevision']]" source="#[payload.revision]" />
            <enrich target="#[message.outboundProperties['thisTimestamp']]" source="#[payload.timestamp]" />
        </enricher>
        </when>
        <otherwise>
        <!-- retrieve the record, increment the rev num by 1 and update timestamp, and update the record -->
            <enricher doc:name="Message Enricher">
                <objectstore:retrieve config-ref="My_Objectstore" key="#[message.outboundProperties['dbDatabase'] + message.outboundProperties['dbCollection']]" doc:name="Retrieve"/>
                <enrich target="#[message.outboundProperties['thisRevision']]" source="#[payload.revision]" />
                <enrich target="#[message.outboundProperties['thisTimestamp']]" source="#[payload.timestamp]" />
            </enricher>
            <set-property propertyName="thisRevision" value="#[message.outboundProperties['thisRevision'] + 1]" doc:name="Increment Rev#"/>
            <set-property propertyName="thisTimestamp" value="#[new Date()]" doc:name="New timestamp"/>
            <objectstore:store config-ref="My_Objectstore" key="#[message.outboundProperties['dbDatabase'] + message.outboundProperties['dbCollection']]" overwrite="true" value-ref="#[['revision' : message.outboundProperties['thisRevision'], 'timestamp' : message.outboundProperties['thisTimestamp']]]" doc:name="Store"/>
        </otherwise>
    </choice>
</sub-flow>