You may always wanted to write your own BPEL activity to handle your scenario. This article will go through step by step process to implement a simple BPEL extension activity for WSO2 BPS and Apache ODE.
WSO2 Business Process Server (BPS) is an easy-to-use open source business process server that executes business processes written using the WS-BPEL standard. It is powered by Apache ODE (open source BPEL engine) and provides a complete Web-based graphical console to deploy, manage and view processes in addition to managing and viewing process instances.
Implementation of Extension Bundle
Create a class by implementing one of the ExtensionOperation interfaces which are available at [1]. The run* method of this class should contain the implementation of the extension activity. You can find a sample implementation of this class at [2].
Then You have to create a class by implementing AbstractExtensionBundle interface. Within this class, the above implemented ExtensionOperation class should be registered. A sample implementation can be found at [3].
Configure WSO2 BPS
There are two methods to expose the extension classes to BPS.
- Creating a jar.
Copy the jar to BPS_HOME/repository/components/lib directory.
- Creating an OSGI bundle
Copy the bundle to BPS_HOME/repository/components/dropins directory.
Add the following configuration entry to the bps.xml file in BPS_HOME/conf directory. Repalce org.wso2.bps.samples.extension by your extension class name.
Note: By default, the sample extension bundles shipped with WSO2 BPS are copied to BPS_HOME/repository/components/lib. You have to add the following configuration to get them registered in BPS.
<bps xmlns="http://wso2.org/bps/config"> ... <extensionBundles> <runtimes> <runtime>org.wso2.bps.samples.extension</runtime> </runtimes> </extensionBundles> ... </bps>Now, restart WSO2 BPS sever, and you are ready to use the new extension in your BPEL.
The process is almost the same for Apache ODE. But there is a separate configuration file to register the extension. Please refer ODE extensions documentation for more details.
Using the Extension activity in your BPEL
Using the Extension activity in your BPEL
The extension must be declared before, it is used.
<bpel:process...> <bpel:extensions> <bpel:extension namespace="#extension-namespace#" mustUnderstand="yes|no"/> </bpel:extensions> ... </bpel:process>If the mustUnderstand attribute is set to yes, then the extension should be registered in BPS server in order to deploy the BPEL process. Otherwise, it will throws an error at the compilation stage of the process. If the mustUnderstand attribute is set to no, then the BPEL process will be deployed without checking whether there is an extension registered in the server.
Using the activity. According to the sample anyElementQName should be equal to b4ptest
<extensionActivity> <anyElementQName standard-attributes> standard-elements </anyElementQName> </extensionActivity>
You can find a sample BPEL process at TestExtensionActivity.zip
References:
[1] - extension
[3] - B4PExtensionBundle.java