Some 'more, in-depth' information on Oracle BPEL PM, ESB and other SOA, day2day things

Monday, July 17, 2006

Async Java Miracles - part 2, or why is my instance not found

Arun from Dubai (and I must admit I am very happy to have fellow readers in the Emirates) wrote in today asking about my note on implementing an Aysnc callback for the BPEL API.

In a nutshell, when he runs his code for an async process he gets the famous ORABPEL-02152
Instance not found

First - why does this happen?
When an async instance is created through the API ( it will be enqueued into the "Delivery Queue", waiting to be picked up by a worker. This guarantees that each message reaching that point cannot get not lost, but implies a natural latency (time from message enqueuing, to time when a worker picks it up to create a physical new instance).

So far the theory - lets get to the code (looks like I forgot to mention this in my previous part so I add the "missing" code piece here)

* CONSTANT: OraBPEL-02152 - Instance not found error
public static final int INSTANCE_NOT_FOUND = 2152;
try {
// try to find the process instance
IInstanceHandle handle =
(_conversationId, _auth);
} catch (ServerException eServerLookupAndFind) {

int errorCode =
// could be that we we are to fast for getting an
// handle on the first attempt, if not we break
if (errorCode != INSTANCE_NOT_FOUND) {
// this is a real one - rethrow
} else {
// this is the case where the instance was not
// found - implement retry here

} catch (RemoteException remoteException) {
// this is a real one - handle it!

Note the catch block, that deciffers the exception, in the case of a ServerException
we can be sure that it contains a root cause - including the error code. It represents the real BPEL error (it's an prmitive int - no OraBPEL though :D ).

With this code in place, you have a handle to make your async callback running smoothly.

Nevertheless it's worth to mention that, every time an instance is not found in the dehydration store you'll see a log entry in the server (domain logs) showing so.


Post a Comment

<< Home