Tuesday, January 25, 2011

OSB Stubs implementing asynchronous callback

I needed to implement a stub acting as follows:

1) request-reply (the reply sends back an ACK)
2) asynchronous callback 10 seconds later to send the response to the request made in point 1

Of course there are zillion of solutions... Citrus Framework, Asynchronous BPEL, a WS with a separate thread to process the callback, a JMS queue...

I decided the - for me - simplest solution: in the main PS, publish to a Callback PS which does a Java Callout to a Thread.sleep(10000), then routes the callback.
Publish is a non blocking operation (in most circumstances, unless you do HTTP with a QoS "exactly once").

It works like a charm. I don't know how OSB implements this non-blocking operation internally, nor which impact a Thread.sleep() has on the bus.... time will tell.... anyway it doesn't go to production, so it doesn't have to be a robust solution.

2 comments:

Unknown said...

Bonjour Pierluigi,

Any issue happened while using a Thread.sleep in a java callout?

david

vernetto said...

no, David, absolutely no issues