How do I listen for custom event and only move forward if certain conditions are met

cancel
Showing results for 
Search instead for 
Did you mean: 
bhattsu
Member II

How do I listen for custom event and only move forward if certain conditions are met

I have a simple process with a a receive task. ( I am ok with any other task type).

I want the receive task to move forward only if an event is received with event type CUSTOM and message="Move Forward"

How do I create a listener for this scenario and how do I throw event using Java API along with message variable. 

5 Replies
salaboy
Senior Member

Re: How do I listen for custom event and only move forward if certain conditions are met

Have you tried in the way that it is described in the documentation? -> Activiti User Guide  ?

kalpesh_c2
Senior Member

Re: How do I listen for custom event and only move forward if certain conditions are met

Hi, Sude Bhat

You can use the event listeners to and set a custom variable value i.e. message="Move Forward" as and check the forward if value is same then do what you want,
Refer this documentation How to create Activiti Event Listener with Spring Boot Example - JavaSampleApproach 

Thanks,
Kalpesh,

ContCentric

bhattsu
Member II

Re: How do I listen for custom event and only move forward if certain conditions are met

Hi Mauricio - 

I have been scratching my head on this. I have read all of these. Nowhere I see an event ExecutionListener that says "oh the message I got is not the one I care about so I will not the wait task to move forward". How can an ExecutionListener prevent a task from moving forward depending what message variable it receives?

bhattsu
Member II

Re: How do I listen for custom event and only move forward if certain conditions are met

 Hi Kalpesh - 

But in this case, the right approach would be to use ExecutionListner right? I read ActivitiEventListener can be only defined at the process level.

I am at "Receive Task" and I want Receive Task to only move forward if I get message="Move Forward".  So I have to put the logic in Receive Task right?

Thank you

kalpesh_c2
Senior Member

Re: How do I listen for custom event and only move forward if certain conditions are met

Yes.