Monday, May 21, 2007

Create a singleton process

This article is based on the one from Matt's blog.

Sometimes you do not want have a process invoked every time. It could have impact on performance, CPU usage or additional memory and derived from this, think about garbage collection. You would like to have a process instance that can be re-used each time. Think about that you want to reuse data that was already available in a process.

What is needed, is a process that 'runs' forever and wait for input to be processed. This can be shown in the next diagram.

The Singleton process is started and will then run forever. It waits until it is accessed from another process, in this case the SingletonAccessor. The Singleton process will increase a counter and return this to the calling process. The basic mechanism is using correlation. The Singleton process is running and is using two correlation sets. One set is used to set correlation on the Singleton process, based on identifier, and one is used to set to the calling process, the Singleton accessors.

Installing the Singleton Process
The demo, download at the end of the article, has been successfully tested with Oracle BPEL PM (for Developers) version edition on Windows and Linux.

The should be unzipped to a local directory (for convince it's suggested that you unzip it in the BPEL Samples directory), in order to be deployed your BPEL PM engine.
  1. Open Oracle JDeveloper
  2. Open the workspace Singleton.jws
  3. Deploy the Singleton process to the BPEL server.
  4. Deploy the SingletonAccessor process to the BPEL server.
note: that the SingletonAccessor process is using a partnerlink pointing to the Singleton process. Make sure the URL is set correct in the bpel.xml file.

<partnerLinkBinding name="Singleton"> <property name="wsdlLocation">
</property> <property name="correlation">correlationSet</property> </partnerLinkBinding>

To run the demo, first initiate the Singleton process from the BPEL Console. ensure that you specify "Singleton/1.0" as the Singleton Id (note - this should be the default payload).

Then initiate as many instances of SingletonAccessor as you like. You should see that they all call the same process instance of Singleton.

Download the example file here.

Post a Comment