what should be the return value for transformMessa

2019-08-26 10:54发布

问题:

In my mule flow I am reading the message form WMQ using WMQ node and then calling a Java class using Java node for required processing of the message.

For the same I have to override the public Object transformMessage(MuleMessage message, String outputEncoding) method. This method is forcing me to return value but I don't require to send any object back.

Can someone please help me to understand what I need to return and why we have to return the value.

Cheers!

回答1:

First thing first, if you return something in your java code it won't automatically be sent back to WMQ like a response. The thing you return in the java node will be propagated to the next node in your flow, which in this case is nothing.

If you don't need to do anything after your java node in the flow I would suggest that you at least return the input payload. This will help you in the future if you would want to add anything after the java node.

The flow will automatically stop after it is finished with the java node.
But if you manipulate the incoming payload some how I would suggest that you return that payload instead for the same reason as above.

For returning the input payload:
return message.getPayload();