Note that there are some explanatory texts on larger screens.

plurals
  1. POMule Studio - pass set variable to Java Transformer
    primarykey
    data
    text
    <p>I've got a flow in mule, and part of it requires two "payload" objects to be passed - one payload is Customer, and the other is Store.</p> <p>The current payload of the flow is set to the Store, and that works correctly being passed into my Java transformer class.</p> <p>I've used Variable (set variable name to Customer) to save my customer payload and am using the property field of my Java Transformer to try and pass that through.</p> <p>Currently it is passing it through to my Java class as a string - rather than the variable it's supposed to be referencing.</p> <p>I've filled out the property field in the transformer as: Name: Customer Value: #[variable:Customer] Reference: </p> <p>Any help would be much appreciated. I am using Mule Studio version 3.4</p> <p>Code excerpts below</p> <p>Mule xml</p> <pre><code>&lt;flow name="query_dos_getStoreStatus" doc:name="query_dos_getStoreStatus"&gt; &lt;choice doc:name="Choice"&gt; &lt;when expression="#[payload.getCustomer()!=null]"&gt; &lt;set-variable variableName="Customer" value="#[payload]" doc:name="Save Customer"/&gt; &lt;custom-transformer class="ServiceDetailsResponseToStores" doc:name="ServiceDetailsResponseStores"/&gt; &lt;custom-transformer class="UpdateIdentifyCustomerResponseForStoreStatus" doc:name="Update Customer for Store status"&gt; &lt;spring:property name="Customer" ref="#[variable:Customer]"/&gt; &lt;/custom-transformer&gt; &lt;remove-variable variableName="GetCustomerDetailsResponse" doc:name="Remove Customer variable"/&gt; &lt;/when&gt; &lt;/choice&gt; &lt;/flow&gt; </code></pre> <p>Java class</p> <pre><code>import org.mule.transformer.AbstractTransformer; import org.mule.transformer.types.DataTypeFactory; public class UpdateIdentifyCustomerResponseForStoreStatus extends AbstractTransformer{ public UpdateIdentifyCustomerResponseForStoreStatus() { super(); this.registerSourceType(DataTypeFactory.create(Store.class)); this.setReturnDataType(DataTypeFactory.create(IdentifyCustomerResponseEnvelope.class)); } protected Object _customer; public Object getCustomer() { return this._customer; } public void setCustomer(Object _customer) { this._customer = _customer; } public Object doTransform(Object payload, String outputEncoding) { if(payload instanceof Store &amp;&amp; _customer instanceof IdentifyCustomerResponseEnvelope) { Store store = (Store)payload; IdentifyCustomerResponseEnvelope customer = (IdentifyCustomerResponseEnvelope)_customer; //changes to customer return customer; } return this._customer; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload