Oracle SOA Suite - Custom Data Publisher for Sensor Action.
This blog will explain the steps to create the custom data publisher for the sensor action in Oracle SOA Suite 11g or Oracle SOA Suite 12c(the same steps will work in Oracle SOA Suite 12c but the screens will be different) .Steps to create custom data publisher
1. Create the java class e.g. MyCustomSensorPublisher that implements the class DataPublisher in the composite project.
Implement the method - public void publish(ITSensorAction action,ITSensorActionData actiondata,Element xml) to publish the event to the custom publisher.
package customjavasensor;
import com.oracle.bpel.sensor.DataPublisher;
import com.oracle.bpel.sensor.schemas.ITHeaderInfo;
import com.oracle.bpel.sensor.schemas.ITSensorAction;
import com.oracle.bpel.sensor.schemas.ITSensorActionData;
import com.oracle.bpel.sensor.schemas.ITSensorData;
import org.w3c.dom.Element;
public class MyCustomSensorPublisher implements DataPublisher{
public MyCustomSensorPublisher() {
}
public void publish(ITSensorAction action,ITSensorActionData actiondata,Element xml) {
ITHeaderInfo header =actiondata.getHeader();
ITSensorData data=actiondata.getPayload();
System.out.println("Sensor "+header.getSensor().getSensorName()+" fired for BPEL Process "+header.getProcessName());
System.out.println("Sensor Data "+xml.toString());
}
}
2. Open the BPEL file and add the sensor.
Right click on the activity and select Create - Sensor
Click on the Sensor Actions and select the Publish Type as Custom and provide the Publish Target as the class name created in the previous step with the package name qualified.
Click on the Activity Variable Sensors and select the corresponding variable.
Deploy the Composite and initiate the same, we can able to see the below output in the log.
Before checking the log file make sure the "Redirect stdout logging enabled" enabled to redirect the System.out logs to the server log file.
Before checking the log file make sure the "Redirect stdout logging enabled" enabled to redirect the System.out logs to the server log file.
Enable Redirect stdout logging enabled:
Login to weblogic server console
Environments - Servers - Click on Server Name(e.g. AdminServer)
Click on Logging - Advanced - Select Redirect stdout logging enabled option and save.
Restart the server
Now the System.out logs will be redirected to server log file (e.g. AdminServer.log)
DOWNLOAD SAMPLE
No comments:
Post a Comment