1 Reply Latest reply on Nov 3, 2011 7:19 AM by Gary tse

    How to trigger a Process by signal from external source?

    Leo Tseng Newbie

      Hi

      I've tried a example that can start a process by signal event in eclipse environment.

       

      Like:

       

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

              try {

                  KnowledgeBase kbase = readKnowledgeBase();

                  StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

                  Map<String, Object> params = new HashMap<String, Object>();

                  params.put("x", "Ya!");

                  params.put("y", "Cool!");

                  ksession.signalEvent("MySignal", params);

              } catch (Throwable t) {

                  t.printStackTrace();

              }       

          }

       

          private static KnowledgeBase readKnowledgeBase() throws Exception {

              KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

              kbuilder.add(ResourceFactory.newClassPathResource("SignalSTest.bpmn"), ResourceType.BPMN2);

              kbuilder.add(ResourceFactory.newClassPathResource("SignalSReTest.bpmn"), ResourceType.BPMN2);

              return kbuilder.newKnowledgeBase();

          }

       

      In Process define:

       

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

            <dataOutput id="_1_Output" />

            <dataOutputAssociation>

              <sourceRef>_1_Output</sourceRef>

              <targetRef>x</targetRef>

            </dataOutputAssociation>

            <outputSet>

              <dataOutputRefs>_1_Output</dataOutputRefs>

            </outputSet>

            <signalEventDefinition signalRef="MySignal" />

      </startEvent>

       

      It does work.

      But my question is,

      when I deploy the process to Guvnor and build the package.

      I don't know how to trigger the process in JBPM server from external environment.

      I know there are some REST command to start the process, but it can't carry parameters like signal does and it can't trigger multiple processes once.

      Is there any way to send a signal into JBPM server in order to trigger a process?

       

      Any suggention will be appreciate.

      Thanks for help.