cancel
Showing results for 
Search instead for 
Did you mean: 

how to fire the servicetask2

harlin-none
Champ in-the-making
Champ in-the-making
I want to execute servicetask2, but I don`t know how to make it happen, there have a message boundary event

xml:

<process id="messageBoundaryEvent" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:class="com.lin.activiti.delegate.MessageDelegate"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <boundaryEvent id="boundarymessage1" name="Message" attachedToRef="servicetask1" cancelActivity="false">
      <messageEventDefinition messageRef="messageEvent"></messageEventDefinition>
    </boundaryEvent>
    <serviceTask id="servicetask2" name="Service Task" activiti:expression="#{printer.printMessage('task has benn message triggered.')}"></serviceTask>
    <sequenceFlow id="flow2" sourceRef="boundarymessage1" targetRef="servicetask2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" sourceRef="servicetask2" targetRef="endevent1"></sequenceFlow>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow4" sourceRef="servicetask1" targetRef="endevent2"></sequenceFlow>
  </process>
2 REPLIES 2

vasile_dirla
Star Contributor
Star Contributor
you could have a look into this test:
MessageBoundaryEventTest

focus on this RuntimeService method:
<code>
/**
   * Notifies the process engine that a message event with the name
   * 'messageName' has been received and has been correlated to an execution
   * with id 'executionId'.
   *
   * The waiting execution is notified synchronously.
   *
   * <p>
   * Variables are set for the scope of the execution of the message event
   * subscribed to the message name. For example:
   * <p>
   * <li>The scope for an intermediate message event in the main process is that
   * of the process instance</li>
   * <li>The scope for an intermediate message event in a subprocess is that of
   * the subprocess</li>
   * <li>The scope for a boundary message event is that of the execution for the
   * Activity the event is attached to</li>
   * <p>
   * Variables are set according to the algorithm as documented for
   * {@link VariableScope#setVariables(Map)}, applied separately to each
   * variable.
   *
   * @see VariableScope#setVariables(Map)
   *      {@link VariableScope#setVariables(Map)}
   *
   * @param messageName
   *          the name of the message event
   * @param executionId
   *          the id of the execution to deliver the message to
   * @param processVariables
   *          a map of variables added to the execution
   * @throws ActivitiObjectNotFoundException
   *           if no such execution exists.
   * @throws ActivitiException
   *           if the execution has not subscribed to the signal
   */
  void messageEventReceived(String messageName, String executionId, Map<String, Object> processVariables);
</code>

thanks vasile.dirla