Thursday, 14 November 2013

BPEL Sensors (Variable,Fault,Activity)



  In This Post we will see how can we define BPEL sensors and in how many ways we can use these sensors for different purposes.
Sensors are used to declare interest in specific events throughout the life cycle of a BPEL process instance. In a business process, that can be the activation and completion of a specific activity or the modification of a variable value in the business process.
When a sensor is triggered, a specific sensor value is created. For example, if a sensor declares interest in the completion of a BPEL scope, the sensor value consists of the name of the BPEL scope and a time stamp value of when the activity was completed. If a sensor value declares interest in a BPEL process variable, then the sensor value consists of the value of the variable at the moment it was modified, a time stamp when the variable was modified, and the activity name and type that modified the BPEL variable.
The data format for sensor values is normalized and well-defined using XML schema.
A sensor action is an instruction on how to process sensor values. When a sensor is triggered by Oracle BPEL Process Manager, a new sensor value for that sensor is created. After that, all the sensor actions associated with that sensor are performed. A sensor action typically persists the sensor value in a database or sends the normalized sensor value data to a JMS queue or topic. For integration with Oracle Business Activity Monitoring, the sensor value can be sent to the BAM adapter.
You can define the following types of sensors, either through Oracle JDeveloper
1) Variable sensors ----Variable sensors are used to monitor variables(or parts of a variable) of a BPELprocess.2) Fault sensors ---- Fault sensors are used to monitor BPEL faults.3) Activity sensors ----Activity sensors are used to monitor the execution of activities within a BPEL process.

Once we create a sensor we can associate an action to it. When a sensor is triggered by Oracle BPEL Process Manager, a new sensor value for that sensor is created. After that, all the sensor actions associated with that sensor are performed. A sensor action typically persists the sensor value in a database or sends the normalized sensor value data to a JMS queue or topic. For integration with Oracle Business Activity Monitoring, the sensor value can sent to the BAM adapter.
When we create a sensor we will get below filesbpel_process_name_sensor.xml --- defines the sensor definitions of a BPEL process.


bpel_process_name_sensorAction.xml --- defines the sensor action definitions of a BPEL process.
Using sensors in BPEL:

Step 1:Create a soa project with BPEL as component (can be any template empty, sync or async)
We will create variable, activity, fault sensors in order respectively.
Now open the bpel process and go to structure window, right click variablesensor and select create variable sensor as below.
Step 2:Give a proper name to sensor and select the variable to which you want to create a sensor and finish the creation.
 Step 3: Now right click activity sensor and select create activity sensor as below.

Give a proper name to sensor and select the activity to which you want to create a sensor and finish the creation.



Step 4:  To create fault sensor right click fault and select create. Now provide the name and select the fault for which we want to create. (In this example we are going with selection failure) as below.


Step 5:  Now we are done with creation of sensors and we are about to create sensor actions.
For this right click sensor actins and select create and then sensor action.

Here give some name and select the publish type as Database.(we have other options, in this sample we are going with database. Infact in BPEL console we will see the sensors with action -publish type as database.)


Database: Publishes the sensor data to the reports schema in the database. The sensor data can then be queried using SQL.
JMS Queue: Publishes the sensor data to a JMS queue.
JMS Topic: Publishes sensor data to JMS topic.
Custom: Publishes the data to custom Java class.
JMS Adapter: Publishes to remote queues or topics. (Above JMS Queue and JMS Topic publish types only publishes to local JMS destinations)




Step 6: Now in edit all the sensors we have cretaed above and select the sensor action thatwe created now as below.

Step 7: Now deploy the composite application and initiate it from em page.
        Now open the instance and go to sensor values tab.
    


In sensor values page we can see the sensors for variable, activity and fault sensors with the values like in below pics.


                                                                                                              By DeepthiReddy


No comments:

Post a Comment