cancel
Showing results for 
Search instead for 
Did you mean: 

End Event ExecutionListener DB Flush Question

gokceng1
Champ in-the-making
Champ in-the-making
Hello,
I've added a custom parse handler for end events(none and error end) to some process definitions. One of them has only 1 service task. The problem arises here. It works like that:

1-While parsing end event it adds an execution listener with ExecutionListener.EVENTNAME_END.
2-This execution listener can call 2 methods according to end event's behavior(none or error)
3-These methods send some process variable to integration channels.
4- These channels process, enrich etc and come up with a result. But this result may need some other variables from process instance.

What a surprise! I have nothing about this process instance in database Smiley Very Happy

What can I do to get notified only after the process ends really? I mean I want to be informed about ending of a process after it completely became history. Is this possible?

Note: I've tried same thing with ProcessParseHandler and ExecutionListener.EVENTNAME_END but it also doesn't write anything to db until execution listener ends.
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
What can I do to get notified only after the process ends really? I mean I want to be informed about ending of a process after it completely became history. Is this possible?

So you mean the variables haven't been flushed to the database yet, but your execution listeners needs it … that's not possible at the moment because it would violate the transactional behaviour of course.

But I understand your use case. One (hacky) solution could be to introduce your own command interceptor that sits above the transaction interceptor.
That way, you can intercept the execution of the command and send the event. But like I said, it's quite hacky in my eyes.

gokceng1
Champ in-the-making
Champ in-the-making
Thank you for response Joram.
In fact I don't need variables at execution listeners, I can get them from delegateExecution. Where I need them is after Spring Integration channels. I send processInstanceId and some other variables to a channel. After that channel a flow starts over integration mechanism, there is no Activiti interception here. Since it is not a direct call, I expect activiti transaction to end when I send it to a channel. In fact I don't like hacky solutions too Smiley Happy I just need the processInstanceId after process ends and flushes to database. I can move forward after that information.

jbarrez
Star Contributor
Star Contributor
Ok I understand better now.

Hmm, if you want the transaction to end , you'd probably need to make the invocation of the execution listener async.
That way, the regular transaction will continue and finish, and the listener execution will be done async afterwards.

julia_bardi
Champ in-the-making
Champ in-the-making
Hi,

I would like to make an execution listener async, but it does not work. I tried adding async="true" and activiti:async="true" as a field to activiti:executionListener. What's the way of doing it?

trademak
Star Contributor
Star Contributor
you can't make the execution listener async. We only support the async attribute on an activity.

Best regards,