I have a very simple scenario here - the requirement is to be able to check whether
a process for orderNR nn is already running.
This check will be done to avoid duplicate order processing.
Here is my simple BPM process, in all its simplicity -
Just my usual BPM Order process.
I create a composite sensor on the incoming orderNr -
I create a test instance for orderNr 345 -
I use the following API code to check for running or processed instances
for that particular orderNr.
------------------------------------------------------------------------------------------
public void findInstanceBySensorValue(String compositeName, String sensorName, String sensorValue){
//
try {
locator = this.getLocator();
} catch (Exception e) {
}
List sFilterList = new ArrayList ();
SensorFilter sFilter =
new SensorFilter(sensorName,
Sensor.SensorDataType.STRING,
Operator.EQUALS,
sensorValue);
sFilterList.add(sFilter);
CompositeInstanceFilter filter = new CompositeInstanceFilter();
filter.setSensorFilter(sFilterList);
filter.setCompositeDN(compositeName);
try {
List compositeInstances = locator.getCompositeInstances(filter);
System.out.println("*** Found " + compositeInstances.size() + " Composite Instances.");
} catch (Exception e) {
}
}
//
public Locator getLocator() throws Exception {
Hashtable jndiProps = new Hashtable();
jndiProps.put(javax.naming.Context.PROVIDER_URL, "t3://localhost:7101/soa-infra/");
jndiProps.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
jndiProps.put(javax.naming.Context.SECURITY_PRINCIPAL, "weblogic");
jndiProps.put(javax.naming.Context.SECURITY_CREDENTIALS, "welcome1");
jndiProps.put("dedicated.connection", "true");
Locator locator = null;
try {
locator = oracle.soa.management.facade.LocatorFactory.createLocator(jndiProps);
} catch (Exception e) {
e.printStackTrace();
}
return locator;
}
------------------------------------------------------------------------------------------
My Tester -
public static void main(String[] args) throws Exception {
Test test = new Test();
MyBPMClientImpl mbci = new MyBPMClientImpl();
// mbci.getAllComposites();
// default/BPMOrders!1.0 345
mbci.findInstanceBySensorValue("default/BPMOrders!1.0", "OrderNrSensor", "345");
}
}
I included the following libraries -
The Tracking api jar can be found here -
JDeveloper project here
I then expose the Client class as a web service -
@WebMethod
public int findInstanceBySensorValue(@WebParam(name = "compositeName") String compositeName,
@WebParam(name = "sensorName") String sensorName,
@WebParam(name = "sensorValue") String sensorValue){
Deploy the web service and test it -
Here I am using SOAP-UI
The Request -
The Response -
a process for orderNR nn is already running.
This check will be done to avoid duplicate order processing.
Here is my simple BPM process, in all its simplicity -
Just my usual BPM Order process.
I create a composite sensor on the incoming orderNr -
I create a test instance for orderNr 345 -
I use the following API code to check for running or processed instances
for that particular orderNr.
------------------------------------------------------------------------------------------
public void findInstanceBySensorValue(String compositeName, String sensorName, String sensorValue){
//
try {
locator = this.getLocator();
} catch (Exception e) {
}
List
SensorFilter sFilter =
new SensorFilter(sensorName,
Sensor.SensorDataType.STRING,
Operator.EQUALS,
sensorValue);
sFilterList.add(sFilter);
CompositeInstanceFilter filter = new CompositeInstanceFilter();
filter.setSensorFilter(sFilterList);
filter.setCompositeDN(compositeName);
try {
List compositeInstances = locator.getCompositeInstances(filter);
System.out.println("*** Found " + compositeInstances.size() + " Composite Instances.");
} catch (Exception e) {
}
}
//
public Locator getLocator() throws Exception {
Hashtable jndiProps = new Hashtable();
jndiProps.put(javax.naming.Context.PROVIDER_URL, "t3://localhost:7101/soa-infra/");
jndiProps.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
jndiProps.put(javax.naming.Context.SECURITY_PRINCIPAL, "weblogic");
jndiProps.put(javax.naming.Context.SECURITY_CREDENTIALS, "welcome1");
jndiProps.put("dedicated.connection", "true");
Locator locator = null;
try {
locator = oracle.soa.management.facade.LocatorFactory.createLocator(jndiProps);
} catch (Exception e) {
e.printStackTrace();
}
return locator;
}
------------------------------------------------------------------------------------------
My Tester -
public static void main(String[] args) throws Exception {
Test test = new Test();
MyBPMClientImpl mbci = new MyBPMClientImpl();
// mbci.getAllComposites();
// default/BPMOrders!1.0 345
mbci.findInstanceBySensorValue("default/BPMOrders!1.0", "OrderNrSensor", "345");
}
}
I included the following libraries -
The Tracking api jar can be found here -
JDeveloper project here
I then expose the Client class as a web service -
@WebMethod
public int findInstanceBySensorValue(@WebParam(name = "compositeName") String compositeName,
@WebParam(name = "sensorName") String sensorName,
@WebParam(name = "sensorValue") String sensorValue){
Deploy the web service and test it -
Here I am using SOAP-UI
The Request -
The Response -
No comments:
Post a Comment