ESB MULE passing the parameters to the java method

匿名 (未验证) 提交于 2019-12-03 08:28:06

问题:

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????

回答1:

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> 


回答2:

  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);



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!