title: Usage of Mule Message Properties
body: <p>Good morning I am trying to set a property and access it. But failed to access the property set.
  I was trying to access a property in SplitterAggregator that is set from the client.
  Following is the mule config. </p>
  
  <pre><code>&lt;flow name="statementRequestFlow"&gt;
  &lt;vm:inbound-endpoint path="statementRequest" /&gt; 
  &lt;vm:outbound-endpoint path="statementSplit" /&gt;
  &lt;/flow&gt;
  &lt;flow name="statementSplitFlow"&gt;
  &lt;vm:inbound-endpoint path="statementSplit" /&gt; 
  &lt;splitter evaluator="xpath" expression="/DocumentJournal/StatementsData/Statement" /&gt;
  &lt;vm:outbound-endpoint path="statementResponse" transformer-refs="domToXml" /&gt;
  &lt;/flow&gt;
  
  &lt;flow name="statementResponseFlow"&gt;
  &lt;vm:inbound-endpoint path="statementResponse" transformer-refs="XmlToStatement"/&gt; 
  &lt;custom-aggregator timeout="5000" class="com.test.splitter.SplitterAggregator"/&gt;
  &lt;component class="com.test.splitter.StatementAggregator"&gt; 
  &lt;method-entry-point-resolver&gt;
  &lt;include-entry-point method="collectStatements"/&gt;
  &lt;/method-entry-point-resolver&gt;
  &lt;/component&gt;
  &lt;/flow&gt;
  </code></pre>
  
  <h1>Following is the client code:</h1>
  
  <p>In this version I simply created a HashMap as props and put a property by name "my_key" and passed it to sendAsync.</p>
  
  <pre><code>String applicationDataAsXml = "&lt;DocumentJournal&gt;...........&lt;/DocumentJournal&gt;";
  MuleClient muleClient = MuleClientSingleton.getMuleClient();
  try {
  Map&lt;String,Object&gt; props = new HashMap&lt;String,Object&gt;();
  props.put("MessageProperties", "MessageProperties");
  props.put("my_key", "my_value");
  muleClient.sendAsync("vm://statementRequest", applicationDataAsXml, props);
  }catch(Exception e) {
  e.printStackTrace();
  }
  </code></pre>
  
  <h1>Following is the custom aggregator:</h1>
  
  <pre><code>public class SplitterAggregator extends AbstractAggregator {
  
  @Override
  public MuleEvent process(MuleEvent event) throws MuleException {
  MuleMessage message = event.getMessage();
  System.out.println("SPlitterAggregator.process(): my_key value: "+ message.getOutboundProperty("my_key"));
  Statement statement = (Statement) message.getPayload();
  System.out.println("SPlitterAggregator.process(): Statement: "+statement.toString());
  return super.process(event);
  }
  </code></pre>
  
  <p>My intent is to access the property "my_key" that is set in the client and access it in SplitterAggregator.process() method.
  It is printed as null.</p>
  
  <h1>Following is the second version of the client code:</h1>
  
  <p>In this version I created DefaultMessage and set "my_key" property with session scope.</p>
  
  <pre><code>String applicationDataAsXml = "&lt;DocumentJournal&gt;...........&lt;/DocumentJournal&gt;";
  MuleClient muleClient = MuleClientSingleton.getMuleClient();
  try {
  DefaultMuleMessage message = new DefaultMuleMessage(applicationDataAsXml, muleClient.getMuleContext());
  message.setSessionProperty("my_key", "my_value");
  muleClient.sendAsync("vm://statementRequest", message);
  }catch(Exception e) {
  e.printStackTrace();
  }
  </code></pre>
  
  <p>When I run the above version of client code I get java.lang.IllegalStateException: Only owner thread can write to message:</p>
  
  <p>Could someone let me know how to make use of properties.</p>
  
  <p>Thanks
  Venkat</p>