code: @Deployment public void testBoundaryMessageEventOnSubprocessAndInsideSubprocess(){
    runtimeService.startProcessInstanceByKey("process");
    assertEquals(5,runtimeService.createExecutionQuery().count());
    Task userTask=taskService.createTaskQuery().singleResult();
    assertNotNull(userTask);
    Execution execution1=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName").singleResult();
    assertNotNull(execution1);
    Execution execution2=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName2").singleResult();
    assertNotNull(execution2);
    assertNotSame(execution1.getId(),execution2.getId());
    taskService.complete(userTask.getId());
    userTask=taskService.createTaskQuery().singleResult();
    assertNotNull(userTask);
    assertEquals("taskAfterTask",userTask.getTaskDefinitionKey());
    Execution execution=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName").singleResult();
    assertNull(execution);
    execution=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName2").singleResult();
    assertNotNull(execution);
    taskService.complete(userTask.getId());
    execution=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName2").singleResult();
    assertNull(execution);
    userTask=taskService.createTaskQuery().singleResult();
    assertNotNull(userTask);
    assertEquals("taskAfterSubprocess",userTask.getTaskDefinitionKey());
    taskService.complete(userTask.getId());
    runtimeService.startProcessInstanceByKey("process");
    execution=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName").singleResult();
    runtimeService.messageEventReceived("messageName",execution.getId());
    userTask=taskService.createTaskQuery().singleResult();
    assertNotNull(userTask);
    assertEquals("taskAfterMessage",userTask.getTaskDefinitionKey());
    execution=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName").singleResult();
    assertNull(execution);
    execution=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName2").singleResult();
    assertNotNull(execution);
    taskService.complete(userTask.getId());
    execution=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName2").singleResult();
    assertNull(execution);
    userTask=taskService.createTaskQuery().singleResult();
    assertNotNull(userTask);
    assertEquals("taskAfterSubprocess",userTask.getTaskDefinitionKey());
    taskService.complete(userTask.getId());
    runtimeService.startProcessInstanceByKey("process");
    execution=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName2").singleResult();
    runtimeService.messageEventReceived("messageName2",execution.getId());
    userTask=taskService.createTaskQuery().singleResult();
    assertNotNull(userTask);
    assertEquals("taskAfterOuterMessageBoundary",userTask.getTaskDefinitionKey());
    execution=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName").singleResult();
    assertNull(execution);
    execution=runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName2").singleResult();
    assertNull(execution);
    taskService.complete(userTask.getId());
  }
  