Hi Jens,
Thanks for posting your process.
The reason why the message cannot be delivered lies in the execution and threading model of the process engine. Here is what happens:
The master process has a timer start event. That means, a job exists that is executed in a regular time interval. "Executing a job" means a single thread is assigned with the task to instantiate the process and execute the process instance until it ends or wait states are reached.
In detail, this means the following steps are executed sequentially within a single thread:
1. A master process instance is created
2. The service task "Send Start Message" begins. The API call it makes is synchronous.
3. A slave process instance is created
4. The service task "Send Notification" is executed
The problem is that at this point, the master process instance has not yet reached the catching message event, because it is still executing the service task "Send Start Message" (as the API call is synchronous). Thus, you see the exception you posted.
In order to avoid this, you can add asynchronous continuations to your process. One possibility would be to make the start event of the slave process asynchronous (property camunda:asyncAfter as an XML attribute of the startEvent element). This would result in the following execution order when the timer job fires:
1. A master process instance is created
2. The service task "Send Start Message" is executed. The API call it makes is again synchronous.
3. A slave process instance is created.
4. Because the "Start Slave Process" is asynchronous, the process engine does not attempt to execute "Send Notification" immediately, but persists a job in the database to continue execution after the start event. The slave process instance has reached a wait state now.
5. The API call from step 2 returns and the service task "Send Start Message" completes.
6. The master process instance reaches the message catch event. A message catch event is as well a wait state because the process instance has to wait for a message. The current process execution state is persisted to the database.
<some time later>
7. The Job executor executes the asynchronous job created in step 4. Now, the master process instance has already reached the catching message event and is able to receive the message properly.
I hope that makes sense. Feel free to ask for clarifications. Some background reading on wait states in processes, transaction boundaries, and how you can control them is provided under [1].
Cheers,
Thorben
[1]
http://docs.camunda.org/latest/guides/user-guide/#process-engine-transactions-in-processes