Thursday, October 28, 2010

Understanding BPELMessageReceiver in BPS

/*Still unfinished stuff, will take time to finish it.*/
Once you invoke a bpel process in WSO2-BPS this is what happens.

It needs to invoke its business logic implemented in bpel. This is somewhat different and somewhat similar to invoking and invoking and Web-Service.
Invoking a bpel process means is just like invoking a WS. So you can use WS client or any other mechanism to call to the WS-interface which is defined by WSDL1.1.
Once the process is invoked, the org.wso2.carbon.bpel.ode.integration.axis2.receivers.BPELMessageReceiver handle the business logic.
Let’s first understand how the BPELMessageReceiver is executed.
Once you start the BPEL server (ODE server), org.wso2.carbon.bpel.ode.integration.BPELServerImpl#initBPELServer, the binding context for the server is set using org.apache.ode.bpel.engine.BpelServerImpl#setBindingContext. There we pass a org.wso2.carbon.bpel.ode.integration.BPELBindingContextImpl object. There org.wso2.carbon.bpel.ode.integration.BPELBindingContextImpl#activateMyRoleEndpoint -> org.wso2.carbon.bpel.ode.integration.BPELBindingContextImpl#publishAxisService -> org.wso2.carbon.bpel.ode.integration.utils.AxisServiceUtils#createAxisService. There the org.wso2.carbon.bpel.ode.integration.axis2.receivers.BPELMessageReceiver object is set as the message receiver for each myRole-endPoint.
So once you invoke a bpel process, BPELMessageReceiver take the responsibility of invoking the business logic.

What happens at org.wso2.carbon.bpel.ode.integration.axis2.receivers.BPELMessageReceiver#invokeBusinessLogic
org.apache.axiom.soap.SOAPFactory object is also created from inMessageContext, for partner service invocation.
There using the inMessageContext of the invocation, BPELMessageContext is generated. It also check whether the operation is in-only or in-out operation. Based on these kind of checkings it generates is custom message context. This is basically just a DTO used when invoking the business logic.

Then the business logic is handles based on whether the operation is in-only or in-out.

In both cases org.wso2.carbon.bpel.ode.integration.BPELProcessProxy#onAxisServiceInvoke is invoked. So let’s look at what happens at this method execution.

Inside org.wso2.carbon.bpel.ode.integration.BPELProcessProxy#onAxisServiceInvoke few important things happens.
One thing is transactionManager.begin() - It creates a new transaction and associate it with the current thread. Default transactionManager is configured in org.wso2.carbon.bpel.ode.integration.config.BPELServerConfiguration.

Then it invokes the BPEL process using the created odeMessageExchange. Here a java.util.concurrent.Future object as follows.

responseFuture = invokeBPELProcessThroughODEMessageExchange(



success = commitODEMessageExchange(odeMessageExchange);

So using responseFuture, process is invoked asynchronously and wait for the response if there is a response.
If there is a response, it’ll be handled.

No comments: