cancel
Showing results for 
Search instead for 
Did you mean: 

How to get listener?

afenske
Champ in-the-making
Champ in-the-making
Hello.

I've got a problem. I have a business process and a client, which is written in Eclipse RCP. My client interacts with the business process through Activiti API.

How can I determine the moment when there is a new task in the queue? In other words, I want to add a listener on the client to catch moments when new task is added to the queue.

Best regards,
Anton Fenske.
16 REPLIES 16

frederikherema1
Star Contributor
Star Contributor
Judging from your process, you already have a task-listener attached to the task (ru.cniieisu.dit.activiti.Task2Listener). From inside that class, you'll get a DelegateTask pointer which offers you everything you need to signal the external system. It's just a matter of hooking/wiring your services (which need to be signaled about task creation/completion) in the JavaDelegate implementation.

afenske
Champ in-the-making
Champ in-the-making
Yes, but it is true just for a task, which has that listener.
But If I want to create universal listener for all tasks, what should I do?
I think to set one listener for all tasks isn't a good idea.

frederikherema1
Star Contributor
Star Contributor
You can use a ParseHandler to add listeners to all tasks when they are parsed to be used in the engine. This way, your BPMN2.0 doesn't contain any listener code, the listeners are added transparently to all processed deployed.

odemwingie
Champ in-the-making
Champ in-the-making
Guys, it's just running in circle. Your advices work only at one PC where we create the new process (Anton has written it in his 3rd and 4th posts), but at the another PC with the same app (surely the configuration is identical with the first one) doesn't catch new process instances - and this is the problem we try to solve!

tcheekva
Champ in-the-making
Champ in-the-making
Sounds like you have 2 engines configured one for each app.  You will have to come up with your own mechanism to communicate between them.  The engines do not talk to each other.  The listeners only have access to events in the engine they are running in..

odemwingie
Champ in-the-making
Champ in-the-making
and is there any examples how to do it somewhere?

frederikherema1
Star Contributor
Star Contributor
Indeed, the 2 process-engines don't communicate with each other. The engine which starts the process will receive the event. The other won't. You'll have to use an external queue, which the task is added to from one of the 2 engines. Than, in the right application, the queue is read out and reacted upon. There is no "general" approach for this. Either use a custom rolled solution or use a messaging-queue product.