Create job dynamically in a task listener

Hi all,
Can we create job in task listener.

The requirement is to create a timer dynamically to send a notification without explicitly modeling it in bpmn.

Regards

Hello @sfaxianovic ,

in the properties panel of a user task, you will find a section “listeners” and inside them a field “Task Listener”. If you add one, you can choose the Event Type “Timeout”.

From what I understand of your request, this should serve your needs.

I hope this helps

Jonathan

Thanks for the response,
Actually this is not what I want to do.
I want to replace this
image
by doing it dynamically with java code

Hello @sfaxianovic ,

in this case, I would determine the timeout before entering the user task (maybe as listener at the sequence flow before) and then use this data as reference in the timer boundary event.

This data can either be a timestamp as joda-time object or an expression according to ISO-8601.

Hope this helps

Jonathan

Thanks for response.
And if (for some cases) I can’t put the timer at modeling time. I want to create it at runtime when some condition are met. Is there any way to create the job of the timer at runtime ?

Hello @sfaxianovic ,

what I described will allow you to determine a timer at runtime (before entering the task this boundary event is attached to).

The Event-Listener at start can define a process instance variable that the timer event is referenced to. By this, the actual timer duration is set at runtime for each instance of this process.

Jonathan

PS: This little example shows how this can be done with an easy script.
dynamicTimer.bpmn (3.8 KB)

Sorry but I think I didn’t explain well my need :confused:
I don’t whant to put the timer in the bpmn. I want to create it in java code, insite a task listener.

Hello @sfaxianovic ,

in this case, the timeout task listener will be the thing you are looking for. Don’t be irritated by its name, it will be triggered after the defined time and will then execute the TaskListener that is referenced.

Jonathan

1 Like