JBoss Community

How to trigger a Process by signal from external source?

created by Leo Tseng in jBPM - View the full discussion

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.

Reply to this message by going to Community

Start a new discussion in jBPM at Community