cancel
Showing results for 
Search instead for 
Did you mean: 

Async Camel task not called

tomas_surovec
Champ in-the-making
Champ in-the-making
Hi, I have an issue with calling async camel service tasks, which is fairly similar to this thread: http://forums.activiti.org/content/async-service-task-not-executing

I have a diagram with parallel gateway forking into two branches, on each branch there are two camel service tasks, followed by join parallel gateway. The camel tasks just log a message and wait a couple of seconds. When I set them to activiti:async = "false", everything works as expected, all tasks print out log messages. The problem start when I set them to be activiti:async = "true" - then nothing appears on log and it looks like that the tasks aren't started at all, because the test finishes almost immediately.

All sources and a diagram screenshot enclosed.
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
Is your job-executor on? Because async activities are executed by that, the call that causes the activities to be queued for execution, returns immediately. That's why the API-call returns…

tomas_surovec
Champ in-the-making
Champ in-the-making
Hi,

yes, that was the issue, thank you!

frederikherema1
Star Contributor
Star Contributor
Glad it works!

tomas_surovec
Champ in-the-making
Champ in-the-making
Although I have another problem: the setup is fairly simple:
START ———> ServiceTask A ————-> ServiceTask B ————–> END

both service tasks are camel tasks that just call a prototype bean's method that just writes out thread id and sleeps for a few seconds on that
thread. Now
1) A, B async = false -> serial call as expected on the same "main" thread
2) A async = false, B async = true -> serial call, second call on different thread (as expected)
3) A async = true, B async = false -> serial call (not expected), second call on the same thread as the first (also not expected behavior)
4) A, B async = true -> B isn't called at all

(btw. acitviti:exclusive="false" always)

I thought that async service task call means that the service is called asynchronously from main thread (the service call being
executed on a different thread) and the main thread continues without blocking, i.e. in 3) it should start executing B immediately and on different
thread than A. Apparently async calls don't work the way I thought - my question is how can I manage to start executing both A and B
concurrently? In other words I want that both service tasks use their own thread, different from "main" thread.

frederikherema1
Star Contributor
Star Contributor
Async indeed means that the activity is executed in another thread, returning control to the main-thread and committing process-state up until the point where the async should start.

3 -> The second task will only be executed once the asynchronous A is complete. When the A is completed by the job-executor thread, it executes B as well on that thread (and any subsequent non-async activities until a wait state or process-end has been reached).

If you want to have both A and B executing at the same time, use a parallel gateway and async=true.