-
1. Re: JBPM 6.1.0.Final custom human task event listener is not working
swiderski.maciej Mar 16, 2015 12:56 PM (in response to soumya.plavaga)there was an issue with task event listeners in 6.1 defined in deployment descriptor that is now solved in 6.2. So best to upgrade. If not possible you can still register event listeners using CDI producers, see docs for details.
HTH
-
2. Re: JBPM 6.1.0.Final custom human task event listener is not working
soumya.plavaga Mar 18, 2015 7:27 AM (in response to swiderski.maciej)Thanks for your reply Maciej. Can you please give an example on how to use CDI producers for Task event Listener ? I have seen there are some listeners within jbpm-audit-6.1.0.Final.jar like 'JPATaskLifeCycleEventListener', 'BAMTaskEventListener' e.t.c. which are getting called when a new task is created. Like that listeners If I create a listener class 'CustomTaskLifeCycleEventListener' which implements TaskLifeCycleEventListener interface, then where and how I need to register this class, so that it is also getting called when a new task is created ?
-
3. Re: JBPM 6.1.0.Final custom human task event listener is not working
soumya.plavaga Mar 18, 2015 9:15 AM (in response to soumya.plavaga)I have tried to use a producer for Task event listener. I have done the following -
Created a producer class 'EibpTaskEventListenerProducer',
@ApplicationScoped
@Alternative
@Selectable
public class EibpTaskEventListenerProducer implements EventListenerProducer<TaskLifeCycleEventListener> {
@Override
@Produces
public List<TaskLifeCycleEventListener> getEventListeners(String identifier, Map<String, Object> params) {
List<TaskLifeCycleEventListener> taskEventListeners = new ArrayList<TaskLifeCycleEventListener>();
taskEventListeners.add(new EibpTaskLifeCycleEventListener());
return taskEventListeners;
}
}
This producer class producing list of listeners with my custom event listener class 'EibpTaskLifeCycleEventListener' which is implementing 'TaskLifeCycleEventListener' interface, where I will be notified when a new task will be created.
I have deployed this producer & listener class as a jar and kept the jar file within jbpm-console's WEB-INF/lib directory. But after server startup, when a new task is created my listener is not picked up.
Can you please advise if I am missing any necessary steps to achieve my requirement ?
-
4. Re: JBPM 6.1.0.Final custom human task event listener is not working
swiderski.maciej Mar 18, 2015 2:36 PM (in response to soumya.plavaga)1 of 1 people found this helpfulfew things:
- make sure you use org.kie.api.task.TaskLifeCycleEventListener as interface of the events listeners
- your jar that is placed in WEB-INF/lib must be a bean archive, meaning it must include marker file META-INF/beans.xml
- @Alternative is not needed as if you use that you must explicitly enable it in beans.xml so I would recommend to remove it
- @Selectable is not needed at all here
HTH
-
5. Re: JBPM 6.1.0.Final custom human task event listener is not working
soumya.plavaga Apr 6, 2015 7:27 AM (in response to swiderski.maciej)Thanks Maciej. It worked.
-
6. Re: JBPM 6.1.0.Final custom human task event listener is not working
swiderski.maciej Apr 13, 2015 2:21 AM (in response to soumya.plavaga)feel free to mark question as answered
-
7. Re: JBPM 6.1.0.Final custom human task event listener is not working
rajiv_dadhich Dec 8, 2015 7:23 PM (in response to soumya.plavaga)Just to help others.
In case, if you wish to not use CDI, you can extend DefaultRegisterableItemsFactory and override getTaskListeners method to return list with added custom listener.
@Override
public List<TaskLifeCycleEventListener> getTaskListeners() {
List<TaskLifeCycleEventListener> taskListeners = super.getTaskListeners();
taskListeners.add(new CustomTaskEventListener());
return taskListeners;
}
Also make sure, you register you new registrableItemsFactory while creating runtime environment.
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefault()
.userGroupCallback(userGroupCallback)
.knowledgeBase(kbase)
.addEnvironmentEntry(EnvironmentName.TRANSACTION_MANAGER,txManager)
.registerableItemsFactory(<customItemsFactory>)
Hope this helps!!
Thanks.