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 10.1.3.1/2 edition on Windows and Linux.
The Singleton.zip 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.
- Open Oracle JDeveloper
- Open the workspace Singleton.jws
- Deploy the Singleton process to the BPEL server.
- Deploy the SingletonAccessor process to the BPEL server.
<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.