【发布时间】:2014-01-07 02:04:04
【问题描述】:
我正在使用 Objectstore 模块来跟踪文档的修订号和时间戳。下面的子流程将出站属性“thisTimestamp”设置为新的 Date()。
<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>
然后使用 ActiveMQ 将消息发送到 JMS 出站端点,并由另一个 ActiveMQ JMS 入站端点接收。记录器显示该属性已在出站范围thisTimestamp=Thu Jan 02 15:04:08 EST 2014 上设置,但相应的入站范围属性为空。什么给了?
编辑添加:有趣的是,当我检查 AMQ 队列上的消息时,thisTimestamp 属性也没有设置。
【问题讨论】:
标签: mule