cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to control TaskListener on UserTask?

swamy2156
Champ on-the-rise
Champ on-the-rise
Hi,

I am facing a problem with Task Listeners. I have simple workflow with 1 UserTask(with Create TaskListener). I am using TaskListener to publish event to JMS Queue. During Task Creation, flow happening like
Task creation(Delegate task)->trigger task listener->persist task data in Database.
Thing is I am getting some DB related exception while persisting data into database and hence task not persisted in database. But task listener already triggered and which is sending a false data to JMS Queue subscribers(in this case because, task is not available).

Is there a way to trigger task listener until a successful transaction is done for UserTask? Please provide me a prototype if available.

Thanks,
Swamy.

5 REPLIES 5

hari
Star Contributor
Star Contributor
Hi Swamy,

Instead of writing the code in the task listener go for a service task. Write your logic in it and hence it will not get executed until your user task has successfully completed.

maudrid
Champ on-the-rise
Champ on-the-rise
Or you can use a script task if you don't want to do a service task.

swamy2156
Champ on-the-rise
Champ on-the-rise
Thank you. I followed Service task as solution for this.

testactivitiuse
Champ in-the-making
Champ in-the-making
So did you have user task followed by service task? Can you please give me more details? I have same problem but I want send message on JMS after task is persisted in DB but not completed.

maudrid
Champ on-the-rise
Champ on-the-rise
Make sure that the Asynchronous flag is set to true on your service task.
The default is false and you will have the same behavior.
http://www.activiti.org/userguide/#asyncContinuations