I'm using the Objectstore module to track a document's revision number and timestamp. The subflow below sets the outbound property "thisTimestamp" as a new 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>
The message is then sent to a JMS outbound-endpoint using ActiveMQ, and received by another ActiveMQ JMS inbound-endpoint. Loggers show that the property has been set on the outbound scope, thisTimestamp=Thu Jan 02 15:04:08 EST 2014
, but the corresponding inbound scoped property is null. What gives?
Edited to add: Interestingly, when I examine the message on an AMQ queue, the thisTimestamp
property is not set either.