Showing posts with label SENSORS. Show all posts
Showing posts with label SENSORS. Show all posts

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


Composite Sensors in Soa 11g



                 In this blog ,I want to discuss about Composite Sensors.Composite sensors provide a method for implementing trackable fields on messages. Composite sensors enable you to perform the following tasks:

  •     Monitor incoming and outgoing messages.
  •     Specify composite sensor details in the search utility of the Instances page of a SOA composite application in Oracle Enterprise Manager Fusion Middleware Control. This action enables you to locate a particular instance.
  •     Publish JMS data computed from incoming and outgoing messages.
  •     Track composite instances initiated through business event subscriptions.

You define composite sensors on service and reference binding components or on service components that have business event subscriptions in Oracle JDeveloper. This functionality is similar to variable sensors in BPEL processes. During runtime, composite sensor data is persisted in the database.


In our case we Use the project we developed for  "Implementing Timeouts in Bpel Using Pick"

Let me remind you the xsd we used  

picksample.xsd
 <xsd:element name="EmployeeDetails">
<xsd:complexType>
<xsd:sequence>
 <xsd:element name="EmpID" type="xsd:string" />
  <xsd:element name="Salary" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="EmpdetailsResponse">
<xsd:complexType>
<xsd:sequence>
 <xsd:element name="EmpID" type="xsd:string" />
 <xsd:element name="MessageStatus1" type="xsd:string" />
 <xsd:element name="MessageStatus2" type="xsd:string" />

</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

Step1: To create sensors ,Click the Composite Sensor icon above the SOA Composite Editor

Step2: Composite sensors window will pop up.Click on "+" icon to create composite sensor.

Step3: In the next window, give the name to sensor and define expression to assingn  value to this sensor.




Step4: You will see the input payload only inand out our usecase as our BPEL process is Synchronous .Drill down to EmpID and click OK.


Step5: Now under sensor actions you will see two options Enterprise Manager and JMS Queue.
  • Enterprise Manager
Select to make runtime sensor data searchable in the Instances tab of a SOA composite application in Oracle Enterprise Manager Fusion Middleware Control.
  • JMS Queue
Select to store composite sensor data (XML payload) in a JMS queue. You must specify the JMS connection factory and queue name.In our case we will use Enterprise Manager

Step6:Our Composite sensor "EmployeeSensor" is created .Click OK.
 Step7: Under your projects on left hand side you can see two new files getting created sensor.xml and sensorActiuon.xml. These files contains list of all the sensors configured for particular composite and along with their actions.

 Step8: Compile and deploy your code to EM and test the Sensors composite from EM

Step9: Now Open up flow trace for the request you triggered.Expand the sensors tab just below Flow Trace.You will see EmployeeSensor as sensor and its value that we passed in the input.



Step10: Go back to your Composite in EM and go to Instances tab.Just next to Search,Reset Buttons you will see a new button :AddFields. Click on that and select EmployeeSensor.



Step11: New search field "EmployeeID" will be added in the Search box along with all other existing search criterias.In this way you can search your instances by passing "EmployeeSensor" field value.


Composite sensors are very important from support and operations point of view as we can set custom search fields using which we can search for our composite instances.

Till now we have seen sensors in Composite.xml

Along with the c omposite sensors we have one more sensors called BPEL sensors which we create in BPEL. We will see these sensors in coming post in detail.


For more Information Check the Below  Sensors


                                                                                                           by DeepthiReddy