Wednesday, May 20, 2015

#400 Using the SOA/BPM APIs to check for running instances (leveraging Sensor Values)

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,
        CompositeInstanceFilter filter = new CompositeInstanceFilter();
        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 =;
        } catch (Exception e) {
        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 -

    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: