Task listener is triggering create event before persisting task in DB
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2016 09:08 PM
I have a workflow like this user task1 -service task —user task2
Now I want process to stop at usertask2 , a task listener is attached to usertask2 and listening on create event. When Create event is fired, a custom Java class publishes a JMS on queue.
There is another piece of Java code in a separate transaction listening to queue and triggers when message arrives, here I am querying activiti DB for user task2 ID which is not in DB yet and throws exception. How could I resolve it? Is there any way to find whether task is persisted in DB before publishing message on queue?
BTW, we use 5.14 version.
Now I want process to stop at usertask2 , a task listener is attached to usertask2 and listening on create event. When Create event is fired, a custom Java class publishes a JMS on queue.
There is another piece of Java code in a separate transaction listening to queue and triggers when message arrives, here I am querying activiti DB for user task2 ID which is not in DB yet and throws exception. How could I resolve it? Is there any way to find whether task is persisted in DB before publishing message on queue?
BTW, we use 5.14 version.
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2016 06:01 AM
" Is there any way to find whether task is persisted in DB before publishing message on queue?"
Yes, you need to CommandContextCloseListener and send the event when the transaction has been committed.
However, I'm pretty sure that CommandContextCloseListener is not available in 5.14 (any reason using such an old version?).
In that version, you'll probably have to use a Transaction listener (don't know the exact name anymore) where you wrap the logic in the post-commit callback.
Yes, you need to CommandContextCloseListener and send the event when the transaction has been committed.
However, I'm pretty sure that CommandContextCloseListener is not available in 5.14 (any reason using such an old version?).
In that version, you'll probably have to use a Transaction listener (don't know the exact name anymore) where you wrap the logic in the post-commit callback.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2016 03:18 AM
Hi Joram,
Activiti has exposed Event as part of 5.15+. These are mentioned as part of activiti user guide under section 3.18 http://www.activiti.org/userguide/index.html#eventDispatcherEventTypes
can additional event listeners for events like TASK_CREATED, TASK_ASSIGNED help in identifying the creation of the usertask2 in above use case?
Activiti has exposed Event as part of 5.15+. These are mentioned as part of activiti user guide under section 3.18 http://www.activiti.org/userguide/index.html#eventDispatcherEventTypes
can additional event listeners for events like TASK_CREATED, TASK_ASSIGNED help in identifying the creation of the usertask2 in above use case?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 02:46 AM
the events are different from what I answered above … that was about sending a CUSTOM event or data to something else.
But yes, the event listener can be used for this, but I think that a regular TaskListener is easier to use in this case.
But yes, the event listener can be used for this, but I think that a regular TaskListener is easier to use in this case.
