cancel
Showing results for 
Search instead for 
Did you mean: 

Queries from 'start' executionListener on first user task.

jenguran
Champ in-the-making
Champ in-the-making
I have a process that goes:
start-> manual task -> user task -> exclusive gateway -> stuff that doesn't matter -> end.
I've put a "start" event execution listener on the first user task. The problem I'm having is, the engine doesn't seem to persist anything until some point past that listener being called. So if I try to query the runtime or history services in my listener, nothing is found. On all the user tasks after the first one I can query for everything.

It looks to me like the thread that starts the process instance runs through the process until it stops at the first wait state. At that point everything is persisted, but the start executionListener has already been called. Is that something that's intended, or could it persist everything and then call the listeners?

My apologies if this has already been asked, I couldn't find anything related to it.
Thanks,
Jerrold
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
Hi,

Nothing is persisted until a wait-state is reached (or the end of the process) so in the listeners, nothing will be flushed to the database (transaction won't be committed). It's not possible to use any API methods (eg. query for timers) from inside listener, this will use another transaction an won't see the changes in the DB, which are pending in the uncommitted transaction used by the process execution.

What functionality are you trying to accomplish?

jenguran
Champ in-the-making
Champ in-the-making
Hello, thanks for the reply.

I'm trying to drop a message on our service bus when we enter a user task. The message would have the name of the process, business key, the user task just entered and the last task finished.

frederikherema1
Star Contributor
Star Contributor
Maybe you can try the folowing:
  • When a task is finished, set a execution-variable with the task's ID (or some other stuff that you need) in an taskListener on the task, event=complete (delegateTask.getExection().setVariableLocally()).

  • When the next task starts, you can use a taskListener, event=start, to send the message you want. Using the passed delegateTask, you can get hold of the variables: delegateTask.getExecution().getVariable('lastFinishedTask'). Info of the current started task is found in the delegateTask itself.

hendrix
Champ in-the-making
Champ in-the-making
Not allowing to query "fresh" data about the process/task trough an executionListener/taskListener seem to limit the usefulness of those…

I have the following scenario:

My ProcessListener is listening to process "end" events to register internally the time and duration of that process instance. I won't be able to do that at the most obvious time: upon process completion. I'm thinking of using that listener only to put the process instance id on some "to be updated" queue so I can later on process what was added to that queue, creating a period of inconsistency on my system.

trademak
Star Contributor
Star Contributor
An option would be to add an async manual task at the end of your process definition (before the end event) and add an execution listener there. Then all previous data of the process instance is persisted, so you should be able to query anything you are looking for.

Best regards,