5 Replies Latest reply on Oct 12, 2012 5:21 AM by shashikalagt

    signal event doesn't work from REST API

    rudi_fisher

      I want to use REST API to call signal. There is some implementation in ProcessMgmtFacade of gwt-console-server for this. I see the source code and I finelly found this in CommandDelegate of jbpm-gwt-core:

       

      {code}

      public void signalExecution(String executionId, String signal) {

         ksession.getProcessInstance(new Long(executionId)).signalEvent("signal", signal);

      }

      {code}

      This doesn't fulfil my requirements so I made changes to this class recompile and redeploy. This step is OK, because I made some other changes about this REST API (start process with params) and everythings work fins, so I think the problem is not in this my changed implementation of CommandDelegate. New implementation is:

       

      {code}

      public void signalExecution(String executionId, String eventType, String eventValue) {

         ksession.getProcessInstance(new Long(executionId)).signalEvent(eventType, eventValue);

      }

      {code}

      I took example of signal event from original examples to be sure that process is designed OK. I took BPMN2-EventBasedSplit.bpmn2. I tested in Eclipse and works fine - after signal call, process cointinued and finally finished. I deployed this process into my Guvnor repo and started by GWT console. Process stopped and waits at signal nodes (see attached picture).

      BPMN2-EventBasedSplit.bpmn2_signal_problem.jpg

      At this point I wanted to push process by send signal event by REST API with new implementation. Method signalExecution in CommandDelegate is called OK and this method take correct process instance (I have log line there to see process instance). But it seems signalEvent on process instance doesn't work. I'm using the same parameters for signal event in Eclipse and in CommandDelegate. I'm confused about what is different between execution in unit test in Eclipse and at server. I made many tests and examples but my probem has no solution to this day. I found some discussion about similar issues but this not solve this problem.

      Working unit test in Eclipse

       

      {code}

      public static final void main(String[] args) throws Exception {

          // load up the knowledge base

          KnowledgeBase kbase = readKnowledgeBase();

          StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

          ProcessInstance processInstance = ksession.startProcess("com.sample.test");

          System.out.println("process instance:" + processInstance.getState());

          ksession.signalEvent("Yes", "YesValue", processInstance.getId());

          System.out.println("process instance:" + ksession.getProcessInstance(processInstance.getId()));

          // NO

          processInstance = ksession.startProcess("com.sample.test");

          System.out.println("process instance:" + processInstance.getState());

          //ksession = restoreSession(ksession, true);

          ksession.signalEvent("No", "NoValue", processInstance.getId());

          System.out.println("process instance:" + ksession.getProcessInstance(processInstance.getId()));

      }

       

      private static KnowledgeBase readKnowledgeBase() throws Exception {

          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

          kbuilder.add(ResourceFactory.newClassPathResource("BPMN2-EventBasedSplit.bpmn2"), ResourceType.BPMN2);

          return kbuilder.newKnowledgeBase();

      }

      {code}

       

      Not working code in CommandDelegate and calling at GWT server

       

      {code}

      ksession.getProcessInstance(new Long(executionId)).signalEvent("Yes", "YesValue");

      {code}

       

      For BPMN2-EventBasedSplit.bpmn2 see official examples in version 5.2.0 Final

        • 1. Re: signal event doesn't work from REST API
          tsurdilovic

          Two things:

          a) Post your process BPMN2 from the Web Designer (BPMN2 button in the footer section)

          b) Try upgrading to the latest designer (http://people.redhat.com/tsurdilo/designer/master) which includes some fixes to the generated BPMN2 of Signal Events and test again. If this still causes issues, then we can  look at a possible CommandDelegate problem I think.

           

          Hope this helps.

          • 2. Re: signal event doesn't work from REST API
            swiderski.maciej

            Difference is that in your unit test you call session.signalEvent and in console signalEvent is done on process instance instead. So that would be why unit test work and in console it does not. I would give a try to change unit test to use process instance signalEvent to keep it consistent. Let us know if that works, as Tihomir said then we could try to look at CommandDelegate if there is anything that could cause any issues.

             

            HTH

            • 3. Re: signal event doesn't work from REST API
              rudi_fisher

              Thank you Tihomir and Maciej, now it works work me. Correct solution was to take the latest version od designer (http://people.redhat.com/tsurdilo/designer/master)

               

              Tihomir, I was already using designer from this master repository but my version was from 13.1.2012 (from maven pom) and after your post I saw there is a new version from 27.1.2012. I took it and start my tests from zero (new deployment of process from eclipse to guvnor repo) and after retest everything is working. It seems this last version fix some problem about signals as you wrote (at least in BPMN export I see differences in value of element signalRef). Thanks.

               

              Maciej, after retest all forms of calling signal is working from Eclipse and also at server (from CommandDelegate class):

              ksession.getProcessInstance(new Long(executionId)).signalEvent("Yes", "YesValue");

              ksession.signalEvent("Yes", "YesValue", new Long(executionId));

              ksession.signalEvent("Yes", "YesValue");

               

              I'm attaching current BPMN export of correct process from designer, maybe this helps someone.

               

              <?xml version="1.0" encoding="UTF-8"?>

              <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.omg.org/bpmn20" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:drools="http://www.jboss.org/drools" id="_MVI7QUp0EeGJ6vd3uFYRmQ" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" expressionLanguage="http://www.mvel.org/2.0" targetNamespace="http://www.omg.org/bpmn20" typeLanguage="http://www.java.com/javaTypes">

                <bpmn2:itemDefinition id="_xItem"/>

                <bpmn2:process id="com.sample.test" drools:packageName="demo" name="Test" isExecutable="true">

                  <bpmn2:property id="x" itemSubjectRef="_xItem"/>

                  <bpmn2:startEvent id="_1" name="Start">

                    <bpmn2:outgoing>_1-_11</bpmn2:outgoing>

                  </bpmn2:startEvent>

                  <bpmn2:eventBasedGateway id="_2" name="Split" gatewayDirection="Diverging">

                    <bpmn2:incoming>_11-_2</bpmn2:incoming>

                    <bpmn2:outgoing>_2-_3</bpmn2:outgoing>

                    <bpmn2:outgoing>_2-_4</bpmn2:outgoing>

                  </bpmn2:eventBasedGateway>

                  <bpmn2:intermediateCatchEvent id="_3" drools:boundaryca="false" name="event">

                    <bpmn2:incoming>_2-_3</bpmn2:incoming>

                    <bpmn2:outgoing>_3-_9</bpmn2:outgoing>

                    <bpmn2:dataOutput id="_3_event" name="event"/>

                    <bpmn2:dataOutputAssociation id="_MVI7Q0p0EeGJ6vd3uFYRmQ">

                      <bpmn2:sourceRef>_3_event</bpmn2:sourceRef>

                      <bpmn2:targetRef>x</bpmn2:targetRef>

                    </bpmn2:dataOutputAssociation>

                    <bpmn2:outputSet id="_MVI7Qkp0EeGJ6vd3uFYRmQ">

                      <bpmn2:dataOutputRefs>_3_event</bpmn2:dataOutputRefs>

                    </bpmn2:outputSet>

                    <bpmn2:signalEventDefinition id="_MVI7REp0EeGJ6vd3uFYRmQ" signalRef="Yes"/>

                  </bpmn2:intermediateCatchEvent>

                  <bpmn2:intermediateCatchEvent id="_4" drools:boundaryca="false" name="event">

                    <bpmn2:incoming>_2-_4</bpmn2:incoming>

                    <bpmn2:outgoing>_4-_10</bpmn2:outgoing>

                    <bpmn2:dataOutput id="_4_event" name="event"/>

                    <bpmn2:dataOutputAssociation id="_MVI7Rkp0EeGJ6vd3uFYRmQ">

                      <bpmn2:sourceRef>_4_event</bpmn2:sourceRef>

                      <bpmn2:targetRef>x</bpmn2:targetRef>

                    </bpmn2:dataOutputAssociation>

                    <bpmn2:outputSet id="_MVI7RUp0EeGJ6vd3uFYRmQ">

                      <bpmn2:dataOutputRefs>_4_event</bpmn2:dataOutputRefs>

                    </bpmn2:outputSet>

                    <bpmn2:signalEventDefinition id="_MVI7R0p0EeGJ6vd3uFYRmQ" signalRef="No"/>

                  </bpmn2:intermediateCatchEvent>

                  <bpmn2:exclusiveGateway id="_5" drools:dg="" name="Join" gatewayDirection="Converging">

                    <bpmn2:incoming>_10-_5</bpmn2:incoming>

                    <bpmn2:incoming>_9-_5</bpmn2:incoming>

                    <bpmn2:outgoing>_5-_6</bpmn2:outgoing>

                  </bpmn2:exclusiveGateway>

                  <bpmn2:scriptTask id="_6" name="Script" scriptFormat="http://www.java.com/java">

                    <bpmn2:incoming>_5-_6</bpmn2:incoming>

                    <bpmn2:outgoing>_6-_8</bpmn2:outgoing>

                    <bpmn2:script>System.out.println("x=" + x);</bpmn2:script>

                  </bpmn2:scriptTask>

                  <bpmn2:endEvent id="_8" name="End">

                    <bpmn2:incoming>_6-_8</bpmn2:incoming>

                    <bpmn2:terminateEventDefinition id="_MVI7SEp0EeGJ6vd3uFYRmQ"/>

                  </bpmn2:endEvent>

                  <bpmn2:scriptTask id="_9" name="Script" scriptFormat="http://www.java.com/java">

                    <bpmn2:incoming>_3-_9</bpmn2:incoming>

                    <bpmn2:outgoing>_9-_5</bpmn2:outgoing>

                    <bpmn2:script>System.out.println("Executing Yes");</bpmn2:script>

                  </bpmn2:scriptTask>

                  <bpmn2:scriptTask id="_10" name="Script" scriptFormat="http://www.java.com/java">

                    <bpmn2:incoming>_4-_10</bpmn2:incoming>

                    <bpmn2:outgoing>_10-_5</bpmn2:outgoing>

                    <bpmn2:script>System.out.println("Executing No");</bpmn2:script>

                  </bpmn2:scriptTask>

                  <bpmn2:scriptTask id="_11" name="Script" scriptFormat="http://www.java.com/java">

                    <bpmn2:incoming>_1-_11</bpmn2:incoming>

                    <bpmn2:outgoing>_11-_2</bpmn2:outgoing>

                    <bpmn2:script>System.out.println("Executing starts.");</bpmn2:script>

                  </bpmn2:scriptTask>

                  <bpmn2:sequenceFlow id="_11-_2" sourceRef="_11" targetRef="_2"/>

                  <bpmn2:sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3"/>

                  <bpmn2:sequenceFlow id="_2-_4" sourceRef="_2" targetRef="_4"/>

                  <bpmn2:sequenceFlow id="_9-_5" sourceRef="_9" targetRef="_5"/>

                  <bpmn2:sequenceFlow id="_10-_5" sourceRef="_10" targetRef="_5"/>

                  <bpmn2:sequenceFlow id="_5-_6" sourceRef="_5" targetRef="_6"/>

                  <bpmn2:sequenceFlow id="_6-_8" sourceRef="_6" targetRef="_8"/>

                  <bpmn2:sequenceFlow id="_3-_9" sourceRef="_3" targetRef="_9"/>

                  <bpmn2:sequenceFlow id="_4-_10" sourceRef="_4" targetRef="_10"/>

                  <bpmn2:sequenceFlow id="_1-_11" sourceRef="_1" targetRef="_11"/>

                </bpmn2:process>

                <bpmndi:BPMNDiagram id="_MVI7SUp0EeGJ6vd3uFYRmQ">

                  <bpmndi:BPMNPlane id="_MVI7Skp0EeGJ6vd3uFYRmQ" bpmnElement="com.sample.test">

                    <bpmndi:BPMNShape id="_MVI7S0p0EeGJ6vd3uFYRmQ" bpmnElement="_1">

                      <dc:Bounds height="30.0" width="30.0" x="25.0" y="65.0"/>

                    </bpmndi:BPMNShape>

                    <bpmndi:BPMNShape id="_MVI7TEp0EeGJ6vd3uFYRmQ" bpmnElement="_2">

                      <dc:Bounds height="40.0" width="40.0" x="232.0" y="60.0"/>

                    </bpmndi:BPMNShape>

                    <bpmndi:BPMNShape id="_MVI7TUp0EeGJ6vd3uFYRmQ" bpmnElement="_3">

                      <dc:Bounds height="30.0" width="30.0" x="318.0" y="25.0"/>

                    </bpmndi:BPMNShape>

                    <bpmndi:BPMNShape id="_MVI7Tkp0EeGJ6vd3uFYRmQ" bpmnElement="_4">

                      <dc:Bounds height="30.0" width="30.0" x="318.0" y="105.0"/>

                    </bpmndi:BPMNShape>

                    <bpmndi:BPMNShape id="_MVI7T0p0EeGJ6vd3uFYRmQ" bpmnElement="_5">

                      <dc:Bounds height="40.0" width="40.0" x="505.0" y="60.0"/>

                    </bpmndi:BPMNShape>

                    <bpmndi:BPMNShape id="_MVI7UEp0EeGJ6vd3uFYRmQ" bpmnElement="_6">

                      <dc:Bounds height="48.0" width="80.0" x="582.0" y="56.0"/>

                    </bpmndi:BPMNShape>

                    <bpmndi:BPMNShape id="_MVI7UUp0EeGJ6vd3uFYRmQ" bpmnElement="_8">

                      <dc:Bounds height="28.0" width="28.0" x="835.0" y="65.0"/>

                    </bpmndi:BPMNShape>

                    <bpmndi:BPMNShape id="_MVI7Ukp0EeGJ6vd3uFYRmQ" bpmnElement="_9">

                      <dc:Bounds height="48.0" width="80.0" x="389.0" y="16.0"/>

                    </bpmndi:BPMNShape>

                    <bpmndi:BPMNShape id="_MVI7U0p0EeGJ6vd3uFYRmQ" bpmnElement="_10">

                      <dc:Bounds height="48.0" width="80.0" x="389.0" y="96.0"/>

                    </bpmndi:BPMNShape>

                    <bpmndi:BPMNShape id="_MVI7VEp0EeGJ6vd3uFYRmQ" bpmnElement="_11">

                      <dc:Bounds height="48.0" width="80.0" x="102.0" y="57.0"/>

                    </bpmndi:BPMNShape>

                    <bpmndi:BPMNEdge id="_MVI7VUp0EeGJ6vd3uFYRmQ" bpmnElement="_11-_2">

                      <di:waypoint xsi:type="dc:Point" x="142.0" y="81.0"/>

                      <di:waypoint xsi:type="dc:Point" x="252.0" y="80.0"/>

                    </bpmndi:BPMNEdge>

                    <bpmndi:BPMNEdge id="_MVI7Vkp0EeGJ6vd3uFYRmQ" bpmnElement="_2-_3">

                      <di:waypoint xsi:type="dc:Point" x="252.0" y="80.0"/>

                      <di:waypoint xsi:type="dc:Point" x="333.0" y="40.0"/>

                    </bpmndi:BPMNEdge>

                    <bpmndi:BPMNEdge id="_MVI7V0p0EeGJ6vd3uFYRmQ" bpmnElement="_2-_4">

                      <di:waypoint xsi:type="dc:Point" x="252.0" y="80.0"/>

                      <di:waypoint xsi:type="dc:Point" x="333.0" y="120.0"/>

                    </bpmndi:BPMNEdge>

                    <bpmndi:BPMNEdge id="_MVI7WEp0EeGJ6vd3uFYRmQ" bpmnElement="_9-_5">

                      <di:waypoint xsi:type="dc:Point" x="429.0" y="40.0"/>

                      <di:waypoint xsi:type="dc:Point" x="525.0" y="80.0"/>

                    </bpmndi:BPMNEdge>

                    <bpmndi:BPMNEdge id="_MVI7WUp0EeGJ6vd3uFYRmQ" bpmnElement="_10-_5">

                      <di:waypoint xsi:type="dc:Point" x="429.0" y="120.0"/>

                      <di:waypoint xsi:type="dc:Point" x="525.0" y="80.0"/>

                    </bpmndi:BPMNEdge>

                    <bpmndi:BPMNEdge id="_MVI7Wkp0EeGJ6vd3uFYRmQ" bpmnElement="_5-_6">

                      <di:waypoint xsi:type="dc:Point" x="525.0" y="80.0"/>

                      <di:waypoint xsi:type="dc:Point" x="622.0" y="80.0"/>

                    </bpmndi:BPMNEdge>

                    <bpmndi:BPMNEdge id="_MVI7W0p0EeGJ6vd3uFYRmQ" bpmnElement="_6-_8">

                      <di:waypoint xsi:type="dc:Point" x="622.0" y="80.0"/>

                      <di:waypoint xsi:type="dc:Point" x="849.0" y="79.0"/>

                    </bpmndi:BPMNEdge>

                    <bpmndi:BPMNEdge id="_MVI7XEp0EeGJ6vd3uFYRmQ" bpmnElement="_3-_9">

                      <di:waypoint xsi:type="dc:Point" x="333.0" y="40.0"/>

                      <di:waypoint xsi:type="dc:Point" x="429.0" y="40.0"/>

                    </bpmndi:BPMNEdge>

                    <bpmndi:BPMNEdge id="_MVI7XUp0EeGJ6vd3uFYRmQ" bpmnElement="_4-_10">

                      <di:waypoint xsi:type="dc:Point" x="333.0" y="120.0"/>

                      <di:waypoint xsi:type="dc:Point" x="429.0" y="120.0"/>

                    </bpmndi:BPMNEdge>

                    <bpmndi:BPMNEdge id="_MVI7Xkp0EeGJ6vd3uFYRmQ" bpmnElement="_1-_11">

                      <di:waypoint xsi:type="dc:Point" x="40.0" y="80.0"/>

                      <di:waypoint xsi:type="dc:Point" x="142.0" y="81.0"/>

                    </bpmndi:BPMNEdge>

                  </bpmndi:BPMNPlane>

                </bpmndi:BPMNDiagram>

              </bpmn2:definitions>

              • 4. Re: signal event doesn't work from REST API
                tsurdilovic

                Yes, until we release Designer version 2.1 I will update the wars on people.redhat.com/tsurdilo/designer/master after every bigger fix, so you have to watch the timestamps to see if updates happened. Once we release the official 2.1 version it will be available on sourceforge as always.

                • 5. Re: signal event doesn't work from REST API
                  shashikalagt

                  can you tell me how to invoke signal from REST API, please  its urgent