Are you struggling with a long running asynchronous Java web method that behaves like a synchronous process when being invoked by an asynchronous BPEL process? Then you may like to know how threading might help you to get rid of the timeout!

Use case

We“™ve set up a SOA composite application on Oracle SOA 11.1.1.6 having an asynchronous service implemented using BPEL (1.1/2.0). A Java web application offers a long running asynchronous web method using JAX-WS, which is invoked by the composite application. Both applications are deployed to the same SOA cluster where we have a timeout of 300s for synchronous BPEL processes (SyncMaxWaitTime):

1

Image 1-Oracle JDeveloper – BPEL Process

Java web application with web method:

@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@Action(input = „asyncJavaApplicationOperation“)
@WebMethod
@Oneway
public void asyncJavaApplicationOperation(@WebParam(name =                                                       „asyncJavaApplicationRequestElement“, partName = „payload“,                                                       targetNamespace = „urn:AsyncJavaApplication“) AsyncJavaApplicationRequestType payload) {

// pause process
{…}
try {
Thread.sleep(request_payload.getWaitTimeInMinutes() * 60 * 1000);
}
// send response
{…}

Pain

If the long running Java web method takes longer than the defined value in the property SyncMaxWaitTime, the instance fails due to a timeout in the BPEL process. If you have a look on the instance via Enterprise Manager, you clearly see its state: faulted, but still running. The Invoke task of the BPEL process which calls the Java application is trapped in a pending state. But why does an asynchronous web method behave like a synchronous one and is blocking the caller?

2

Image 2-Enterprise Manager – Service Dashboard

3

Image 3-Enterprise Manager – Instance audit trail – Invoke is pending

Solution

The BPEL process expects an acknowledgement by the Java web method. Otherwise it is processed like a synchronous request. The Java application does not send an acknowledgement until its web method has finished. To get rid of this behavior, create a new thread in your Java application and put your long running tasks into that thread:

@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@Action(input = „asyncJavaApplicationOperation“)
@WebMethod
@Oneway
public void asyncJavaApplicationOperation(@WebParam(name =                                                      „asyncJavaApplicationRequestElement“, partName = „payload“,                                                       targetNamespace = „urn:AsyncJavaApplication“) AsyncJavaApplicationRequestType payload) {
{…}

Thread t1 = new Thread(new Runnable() {
public void run() {
letMeWaitBeforeCallingMeBack(request_payload,response_payload);
}
});

t1.start();
}

private void letMeWaitBeforeCallingMeBack(AsyncJavaApplicationRequestType request_payload, AsyncJavaApplicationResponseType response_payload){

// pause process
{…}
try {
Thread.sleep(request_payload.getWaitTimeInMinutes() * 60 * 1000);
}

// send response
{…}
}

By starting a new thread, the Java web method now can finish and returns the acknowledgement to the invoking BPEL process. The Invoke task now is completed immediately and the process will go on to the Receive task to keep on waiting for the callback

-> Receive task now is pending instead of the Invoke task (compare Image 3 with Image 4).

4

Image 4-Enterprise Manager – Instance audit trail – Receive is pending

Once the long running process has finished as well, the callback is sent to the BPEL process without struggling with timeouts.

5

Image 5-Enterprise Manager – Instance audit trail – Receive was successful

Alle Beiträge von Thomas Fischer

2 Kommentare

    • Thomas Fischer Reply

      Hi,
      yes, there only is input defined for the operation in the WSDL. Therefore the generated method asyncJavaApplicationOperation does not return anything (public void asyncJavaApplicationOperation)

Schreibe einen Kommentar