cancel
Showing results for 
Search instead for 
Did you mean: 

NPE when trying to signal Receive Task

daveychu
Champ in-the-making
Champ in-the-making
Hello everyone,

I'm trying to model a process where users receive a mail after which they need to verify that they read it. If they haven't verified after a certain period, another mail should be send. This should continue indefinitely until either all users have verified the mail or someone overrides the process.

The following schema shows how I modeled the happy flow where users always immediately verify upon receiving the mail.

http://imgur.com/Rd3Ojby

The sub-process is called for each e-mail in a collection of e-mails that is set on the process context when starting the process. The "Send mail" ServiceTask sends an e-mail to someone with the execution ID in the message body. (DelegateExecution.getId()) Using the console, I enter the number and call RuntimeService.signal(id) where id is the number I just received from the mail. Once I do this for all e-mails, the process continues as expected and "Hello World" is printed to the console.

Next, I try to send an e-mail every n-period while no signal has been received.

http://imgur.com/4AUDEDq

When I run this process, I will indeed get an e-mail every n-period. However, when I now signal the execution ID I get the exception as shown in the image.

Is this the right way to model what I'm trying to achieve? If so, how can I resolve this issue? If not, how would you recommend these requirements to be modeled?

Thank you very much,
Davey
6 REPLIES 6

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Davey,

Could you create jUnit test to reproduce this exception?
To solve your problem use following jUnit test from activiti source:
org.activiti.engine.test.bpmn.event.timer.IntermediateTimerEventTest#testLoop

Regards
Martin

Hello Martin,

I reproduced the problem via JUnit test as requested.

Kind regards,
Davey

martin_grofcik
Confirmed Champ
Confirmed Champ
Hello Davey,

Thank you for the jUnit test - it makes things much easier.
I cloned it - but I do not have access to push changes and I do not want to fork your repository. That's why I post the solution here:


  @Test
  @Deployment(resources = {"diagrams/MyProcess.bpmn"})
  public void testName() {
    ProcessInstance pi = rule.getRuntimeService().startProcessInstanceByKey("myProcess");
    Execution execution = rule.getRuntimeService().createExecutionQuery()
      .processInstanceId(pi.getId())
      .activityId("receivetask1")
      .singleResult();
    assertNotNull(execution);

    rule.getRuntimeService().signal(execution.getId());

    assertThat("after the receive task [receivetask1] all process instances are finished",
      rule.getRuntimeService().createProcessInstanceQuery().count(), is(0L));
  }


Regards
Martin

Your unit test works exactly as required. Thank you Martin! Is there an expected way to mark this topic as solved?

Kind regards,
Davey

jbarrez
Star Contributor
Star Contributor
No, sorry, no such feature here. But thanks for posting back that it works 🙂

owais1
Champ on-the-rise
Champ on-the-rise
Hi Davey,
I have a requirement wherein I am using a receive task to make a process wait until the receive task gets the required ID to continue the process.I have referred the following link:http://forums.activiti.org/content/correct-way-signal-receivetask but could not achieve the desired as I am getting errors in the code.Can you help with your code for my reference.