This Question relates to Mule ESB 3.2.
If I have read values from JMS, transform to JSON and store the values in my session like this:
<message-properties-transformer scope="session" doc:name="save values to session">
<add-message-property key="id" value="#[json-node://id]"/>
<add-message-property key="name" value="#[json-node://name]"/>
</message-properties-transformer>
<component class="org.mule.example.echo.Echo"/>
How do I access these property values from a java component?
First of all, your class must implement the org.mule.api.lifecycle.Callable
interface. Then you can get the properties values inside the onCall
method like this
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
String id = eventContext.getMessage().getProperty("id", PropertyScope.SESSION);
String name = eventContext.getMessage().getProperty("name", PropertyScope.SESSION);
//Do the rest of your stuff
}