In the last few weeks I've tried some of the jBPM-ESB integration features. Now and then I run into trouble with the payload location. I would like to discuss the problems with you.
The EsbActionHandler (and EsbNotifier too) is able to map jBPM context variables to the ESB message. See samples and docs for the element. Sometimes (maybe most of time) you map more than one variable. Each mapping is given a name by the "esb" attribute. Inspecting the resulting ESB message you will see that the body of the message contains one object for each variable. They all can be retrieved inside the actions by calling
message.getBody().get("myVariableName")
This approach works fine when developing custom actions.
But is does not work with all these useful ESB actions supplied out-of-the-box. For example the org.jboss.soa.esb.actions.soap.SOAPClient or org.jboss.soa.esb.actions.Notifier. As described in the Programmers Guide in section "Getting and Setting Data on the Message Body" all standard ESB actions expect the payload as a single object located at the default payload location. This object can be a String, a byte-array, a Map containing several more Java objects, or anything else. Nevertheless they all expect a single object. This message format is not compatible with ESB messages created by the EsbActionHandler.
After discovering this contradiction I thought about using the SmooksAction to transform the message format. Unfortunately the SmooksAction expects a single object at the default payload location too :-(
Another work-around is to configure a different default payload location. But this work-around only helps with a single variable.
Now I am thinking about patching the EsbActionHandler to store all mapped variables inside a Map at the default payload location.
I would be grateful for any ideas on this topic. Thanks in advance!