|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Setting and Reading properties on MuleMessageHi all,
I'm stuck in a problem with message properties. The task I'm trying to accomplish is straightforward: I would set a property in a mule message using a message-properties-transformer in the inbound router and read the value in the outbound endpoint using expression framework Im more depth, here's my configuration: <service name="local.eventi.update.write"> <inbound> <vm:inbound-endpoint path="local.eventi.update.write" connector-ref="directVm" > <message-properties-transformer> <add-message-properties key="tstamp" value="2009-10-01"/> </message-properties-transformer> </vm:inbound-endpoint> </inbound> <outbound> <chaining-router> <jdbc:outbound-endpoint connector-ref="DB_VLOCAL_AZIENDE" synchronous="true" queryKey="batchReplaceEventi" /> <vm:outbound-endpoint path="recs.console.insert" transformer-refs="local.eventi.update.write.ok" connector-ref="directVm"> </vm:outbound-endpoint> </chaining-router> </outbound> </service> But the message received by the component doesn't contains the property "tstamp". So I changed my inbound configuration to this: <vm:inbound-endpoint path="local.eventi.update.write" connector-ref="directVm" > <property key="tstamp" value="2009-10-01"/> </vm:inbound-endpoint> and that seems to work (the tstamp property is added to the message) In my outbound router,I tried to access the variable using the following expressions: #[mule:message.headers(tstamp)] #[mule:message.header(tstamp)]#[headers:tstamp] #[header:tstamp] but the result is always null. So, my questions are: 1- what am I doing wrong with the message-properties-transformer ? Wasn't it supposed to do exactly what I wanted to do? 2- how can I read via expression evaluation the tstamp property? Thank to all in advance, stefano --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
|
|
|
Re: Setting and Reading properties on MuleMessageOk, I fixed the problem by myself. There was a problem with some custom code accessing the property value.
But I still have a question about setting the property. The only way I found to set a dynamic value in my message header was via <script:transformer>: <vm:inbound-endpoint path="local.eventi.update.write" connector-ref="directVm" > <script:transformer> <script:script engine="groovy"> import java.text.DateFormat; import java.text.SimpleDateFormat; DateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm"); message.setProperty("tstamp",f.format(new GregorianCalendar().getTime())); return message; </script:script> </script:transformer> </vm:inbound-endpoint> because <property> tag doesn't seem to evaluate dynamic expression and <message-property-transformer> doesn't seem to set the property at all .I think I'm missing something using of message-property-transformer. What is it supposed to do? I don't like very much groovy scripts in my configuration file, so I would ask if someone knows a better way to do that. s. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |