In this recipe, we will examine how to define composite sensors for tracing purposes. Further, we will also show you the ways to define sensors in a BPEL process. We define composite sensors at the level of SCA when we want to monitor input and output messages of a BPEL process. Composite sensors also provide a convenient way of tracking fields on messages.
As a starting point, we need a BPEL process. We can define a new one or reuse an existing one. For this recipe, we will extend the BPEL process that we used in the Creating a custom logger in a BPEL process recipe.
In this recipe, we will walk through the steps needed to define a composite sensor in SCA:
The most interesting part of the composite sensor definition is the Add dialog. The fields in the dialog have the following meaning:
The Oracle SOA Suite also provides the ability to define the sensors inside a BPEL process. Three types of sensors can be defined: variable, activity, and fault. We use the BPEL sensors to collect information that is interesting to us during the BPEL process instance lifecycle. Within the business process, we can check the activation and completion of a specific activity or monitor a modification of a variable value inside the BPEL process. The activity sensors are used to monitor the execution of an activity. It is also possible to monitor the variables of an activity. Variables sensors are used to monitor the variable of a BPEL process, for example, input and output messages. Fault sensors are used to monitor BPEL process faults.
In JDeveloper, in the top-right of the BPEL layout window, we click on the Monitor button. We are going to define a variable sensor to monitor the room price in the BPEL process:
RoomPriceSensor
)$GetRoomPrice_getPrice_InputVariable/parameters/ns2:getPrice
)VariableConfig
tag in next code)<sensor sensorName="RoomPriceSensor" classname="oracle.tip.pc.services.reports.dca.agents.BpelVariableSensorAgent" kind="variable" target="$GetRoomPrice_getPrice_InputVariable/parameters/ns2:getPrice"> <variableConfig outputDataType="getPrice" outputNamespace="http://axis.ws.packt.org"/> </sensor>
BPELProcessSeq_sensor.xml
. This file holds the sensor definitions.Similar to defining a variable sensor, we can define an activity sensor in BPEL as shown in the following steps:
RoomPriceSensorActivity
).GetRoomPrice
).
Evaluation time |
Description |
---|---|
Activation |
This evaluation is performed just before the activity is executed. |
Completion |
As opposed to the Activation, this evaluation is performed immediately after the activity is executed. |
Fault |
The sensor is evaluated in case of fault occurrence during the activity execution. |
Compensation |
The sensor is evaluated when the associated scope is compensated. When the BPEL process has a compensation handler defined and the fault occurs in the BPEL process, the compensation handler procedure is executed. At the start of the compensation activity, the event is fired to monitor the activity. |
Retry |
The sensor is evaluated when the activity is retried. |
All |
The sensor includes all of the above situations. |
We define the activity sensor of the GetRoomPrice
Invoke activity. We will check the sensor value upon the completion of the activity as shown in the following code:
<sensor sensorName="RoomPriceSensorActivity" classname="oracle.tip.pc.services.reports.dca.agents.BpelActivitySensorAgent" kind="activity" target="GetRoomPrice"> <activityConfig evalTime="all"> <variable outputDataType="RoomPrice" outputNamespace="http://axis.ws.packt.org/xsd" target="$GetRoomPrice_getPrice_OutputVariable/parameters/ns2:getPriceResponse/ns2:return"/> </activityConfig> </sensor>
Similar to defining a variable and activity sensor, we can define a fault sensor in BPEL as shown in the following steps:
CarFaultSensor
)sns1:BookCarServiceInvalidDatesException
)<sensor sensorName="CarFaultSensor" classname="oracle.tip.pc.services.reports.dca.agents.BpelFaultSensorAgent" kind="fault" target="sns1:BookCarServiceInvalidDatesException"/>
The sensors in BPEL have a wider range of sensor actions than the ones in composite. The sensor actions define where the sensor data will be published. Depending on the sensor action we define, the sensor data gets published into the defined endpoint. The sensor actions that can be associated with BPEL sensors are as follows: