Detecting Process Shutdown/Startup Events through ActivationAgents

Ramkumar Menon
Director, Product Strategy

@10g - This post is motivated by one of my close friends and colleague - who wanted to proactively know when a BPEL process shuts down/re-activates. This typically happens when you have a BPEL Process that has an inbound polling adapter, when the adapter loses connectivity to the source system. Or whatever causes it.

One valuable suggestion came in from one of my colleagues - he suggested I write my own ActivationAgent to do the job. Well, it really worked.

Here is a sample ActivationAgent that you can use.

There are few methods you need to override from BaseActivationAgent, and you are on your way to receiving notifications/what not, whenever the shutdown/startup events occur.

In the example below, I am retrieving the emailAddress property [that is specified in your bpel.xml activationAgent section] and use that to send out an email notification on the activation agent initialization. You could choose to do different things. But bottomline is that you can use the below-mentioned API to access the very same properties that you specify in the bpel.xml.

package com.adapter.custom.activation;

import com.collaxa.cube.activation.BaseActivationAgent;

import com.collaxa.cube.engine.ICubeContext;

import com.oracle.bpel.client.BPELProcessId;

import java.util.Date;

import java.util.Properties;

public class LifecycleManagerActivationAgent extends BaseActivationAgent {

public BPELProcessId getBPELProcessId() {

return super.getBPELProcessId();


private void handleInit() throws Exception {

//Write initialization code here

System.err.println("Entered initialization code....");

String emailAddress = getActivationAgentDescriptor().getPropertyValue(emailAddress);

//send an email



private void handleLoad() throws Exception {

//Write load code here

System.err.println("Entered load code....");


private void handleUnload() throws Exception {

//Write unload code here

System.err.println("Entered unload code....");


private void handleUninit() throws Exception {

//Write uninitialization code here

System.err.println("Entered uninitialization code....");


public void init(ICubeContext icubecontext)

throws Exception {


System.err.println("Initializing LifecycleManager Activation Agent .....");



public void unload(ICubeContext icubecontext)

throws Exception {


System.err.println("Unloading LifecycleManager Activation Agent .....");



public void uninit(ICubeContext icubecontext)

throws Exception{


System.err.println("Uninitializing LifecycleManager Activation Agent .....");



public String getName() {

return "Lifecyclemanageractivationagent";


public void onStateChanged(int i, ICubeContext iCubeContext) {


public void onLifeCycleChanged(int i, ICubeContext iCubeContext) {


public void onUndeployed(ICubeContext iCubeContext) {


public void onServerShutdown() {



Once you compile this code, generate a jar file and ensure you add it to the server startup classpath. The library is ready for use after the server restarts.

To use this activationAgent, add an additional activationAgent entry in the bpel.xml for the BPEL Process that you wish to monitor.

After you deploy the process, the ActivationAgent object will be called back whenever the events mentioned in the overridden methods are raised. [init(), load(), unload(), uninit()]. Subsequently, your custom code is executed.

Sample bpel.xml illustrating activationAgent definition and property definition.

<?xml version="1.0" encoding="UTF-8"?>

<BPELSuitcase timestamp="1291943469921" revision="1.0">

<BPELProcess wsdlPort="{http://xmlns.oracle.com/BPELTest}BPELTestPort" src="BPELTest.bpel" wsdlService="{http://xmlns.oracle.com/BPELTest}BPELTest" id="BPELTest">


<partnerLinkBinding name="client">

<property name="wsdlLocation">BPELTest.wsdl</property>


<partnerLinkBinding name="test">

<property name="wsdlLocation">test.wsdl</property>




<activationAgent className="oracle.tip.adapter.fw.agent.jca.JCAActivationAgent" partnerLink="test">

<property name="portType">Read_ptt</property>


<activationAgent className="com.oracle.bpel.activation.LifecycleManagerActivationAgent" partnerLink="test">

<property name="emailAddress">ramkumarmenon@toottoot.com</property>






Join the discussion

Comments ( 1 )
  • Hilda Colyott Wednesday, April 27, 2011
    Generally I do not read article on blogs, but I would like to say that this write-up very forced me to try and do so! Your writing style has been surprised me. Thanks, very nice post.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.