AnsweredAssumed Answered

Activiti and JMS (mapping messages and signals to JMS msgs)

Question asked by odranoel75 on Dec 18, 2012
Latest reply on Dec 21, 2012 by jbarrez
I have two questions about Activiti BPMN:

1) How do I parse message definitions programmatically

2) How do I trap intermediateThrowEvent events programmatically.

I'm working on a project that will use an embedded Activiti BPMN engine (currently version 5.11). The application is currently driven by sending and receiving JMS messages, and I thought it would be a natural fit to expose them as Activiti messages and signals. The application has to enable many separate JVMs each running a single BPMN engine with various processes to both send and receive messages between each other.

I have a few thoughts on how to implement each scenario, but I'm unsure on how to parse the messages from my BPMN process to implement Option 2a, and I'm unsure of how to trap the intermediateThrowEvent to implement Option 1b:

a) Receiving messages:

Option 1a - subscribe to a single topic where all JMS messages arrive, and put the Activiti message or Activiti signal name inside the JMS messages as a payload. When a JMS message arrives, I can then query the engine each to see which current Executions are subscribing to the messages, and which Processes need to be started:

List<ProcessDefinition> pds= repositoryService.createProcessDefinitionQuery()

for (ProcessDefinition pd: pds)
    di.getId().toString(), processVariables);
Option 2a - subscribe to a dynamic topic that maps directly to the Activiti message name or Activity Signal name. The tricky part here is how to parse the message or signal name from the BPMN process. I've managed to parse the message reference by using a custom BpmnParseListener, but I can only get the message reference, and not the message name from within the implementation.

pec = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
  if (pec instanceof ProcessEngineConfigurationImpl)

    List<BpmnParseListener> preParseListeners = new ArrayList <>();

    preParseListeners.add(new BPMNMessageAndSignalParser(pontus));

    ((ProcessEngineConfigurationImpl) pec).setCustomPreBPMNParseListeners(preParseListeners );

b) Sending Messages:

Option 1b) I'd like to ideally trap the intermediateThrowEvent, so I can send the signal as a JMS message, but I'm not sure how to do that.

I'm fairly new to Activiti, so apologies if I've missed anything obvious; also, here's a sample workflow just to help put the issue in context:

<?xml version="1.0" encoding="UTF-8" ?>
<definitions id="definitions"
  <message id="pontusMessage" name="pontusMessage"/>
  <signal id = "pontusSignal" name="pontusSignal"/>
  <process id="test" name="PontusNetworks Test" isExecutable="true">

    <startEvent id="start" />

    <sequenceFlow id="flow1" sourceRef="start" targetRef="messageReceiver" />

    <intermediateCatchEvent id="messageReceiver">
        <messageEventDefinition messageRef="pontusMessage" />

    <sequenceFlow id="flow2" sourceRef="messageReceiver" targetRef="signalSender">

    <intermediateThrowEvent id="signalSender">
        <signalEventDefinition signalRef="pontusSignal" />
    <sequenceFlow id="flow3" sourceRef="messageReceiver" targetRef="theEnd2"/>

    <endEvent id="theEnd2" />


Thanks in advance for any ideas.