2

I use MULE version 3.3.0 CE, I want to get some value from header in inbound and then pass it to a java method, in java method making some changes on passed value, finally again I pass it from java method to the outbound????

brelian
  • 403
  • 2
  • 15
  • 31

2 Answers2

7

Instead of tying your Java beans to the Mule API (with Callable), you can do this using MEL only, for example with:

<invoke object-ref="yourBean"
        method="yourMethod"
        methodArguments="#[message.inboundProperties['inboundPropertyName']]" />

<set-property propertyName="outboundPropertyName"
              value="#[payload]" />

This has the caveat that the message payload is affected by the invoke element. If this is a problem then you can go with:

<expression-component>
    propVal = app.registry.yourBean.yourMethod(message.inboundProperties['inboundPropertyName']);
    message.outboundProperties['outboundPropertyName'] = propVal;
</expression-component>
David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • In the second form, are flowVars/InvocationProperties considered inbound, outbound, or something else? – mmeyer Dec 23 '13 at 21:45
  • Something else: they are flow variables, i.e. accessible in the `flowVars` map and, unless you deactivated this feature, as global variables of the MEL script. – David Dossot Dec 24 '13 at 01:01
3
  1. Make your Java component implement org.mule.api.lifecycle.Callable
  2. In its onCall you can get the message as follows:

    MuleMessage message = eventContext.getMessage();

  3. Now you can obtain the inbound properties:

    Object someProp = message.getInboundProperty("some_prop_name");

  4. After operating over it, you place it back as an outbound property:

    message.setOutboundProperty("some_prop_name", someProp);

Seba
  • 2,319
  • 15
  • 14
  • thanks for your reply. :) Can you more explain about it? first I set a variable in .mflow file then in java class callable get it ?? – brelian Mar 05 '13 at 15:43