Timer Event (after or before a Task)

Timers are programmed into the Engine, so do not need any outside code to use.

Thank you. I’m currently in tears because I really don’t know how to achieve what I wrote about in the other threads regarding programming.

Hello!

Just a visual addition to the comments from the @GotnOGuts master!

For boundary events, we can have 2 types, they are interrupting (with solid borders) and non-interrupting (dashed borders).

Below I created an example to facilitate the understanding of an interrupting.

  • Imagine that you ordered a pizza, but you are very hungry… if the pizza takes 2 hours to arrive, you will no longer receive it, you will simply stop waiting for it to arrive, and will refuse the pizza, and will cook some food. This is the behavior of the interrupting event, simply stop the current activity, give up on it and go down the flow path where it is linked to the timer.

  • For non-interrupting boundary events, imagine that an employee has a certain activity to do, and if it doesn’t finish within 2 hours, you want to trigger an email to the CEO informing that the activity hasn’t been finished yet, but you don’t want to remove the activity from the employee, you want to leave the activity with him so that he can continue doing it.

It is in cases like this that we use non-interrupting.

image

Regards.
William Robert Alves

Thank you. So, in a non-interrupting boundary event, both the “Take a Coffee Break” task and the “Send Mail” token will flow.

Only if the worker is still performing “Do the requested activity” after 2h.

So that mean if its before 2 hours like after 1 hour only the task Take a Coffee Break will Start but after 2 hours both tasks get started. Did I understand it correctly?

I’m not sure, because the question isn’t clearly stated.

If:
0800 - Start Event (Start)
0800 - Start Event (End)
0800 - “Do the requested Activity” (Start)
xxxx - “Do the requested Activity” (End)
xxxx - “Take a Coffee Break” (Start)

If xxxx < 1000, then ONLY “Take a Coffee Break” will happen
If xxxx >= 1000, then “Send an Email” will start at 1000 (and likely end at 1000).

The above is focusing on how BPMN works. Where things start to get confusing is when we start to try to immediately also mix in Camunda Implementation.
“Do the Requested Activity” and “Take a Coffee Break” are user tasks, so they need Tasklist (a UI to the tasks, which is a very special form of worker application)
“Send an EMail” requires a Task Worker, which is an outside program that asks the Camunda Engine “Do you have any work for me?” every few seconds. If there’s something for the Task Worker to do, then it does it. Most (if not all) Task Workers are programs you need to write. You can use your preferred language, as per your other threads.

I thought that if it’s greater than 10, both tasks will be executed. I have a request, could you show me the code for that? Unfortunately, I can’t find any documentation on it.

Yes, both will be executed.
at 1000, “Send an Email” will be available for an email worker to claim.
at xxxx, “Take a Coffee Break” will be available for a human worker to claim.

Let’s stay away from Implementation for now.
Let’s stick to understanding how BPMN works. Once you’ve got that solid, then we can look at implementation.

Now I understand it thanks to you. I know if he waits for the requested activity and nothing happens after 2 hours both tasks will be executed

One last question, as I understood, I can’t set when the task expires in my timer events. Is there an alternative way I could do that?

Hello!
Yes, you can!

Put a “Timer boundary event” in the task that you want to have an expiration date, defining how long the task can run, if the time ends and the task has not finished, the task will expire and your instance will exit this task in Camunda.

Keep in mind that there are 2 types of timers, the interruptive and non-interrupting timer.

The interrupt is the one with a double border, and this is what expires the activity, that is, it makes its instance leave the current task when the timer expires.

The non-interrupting, is the one with the dashed border, and when the timer is activated, it creates a kind of “strand” of your instance to execute some other activity without ending your current activity.

As in the example I gave in the messages above, using a non-interrupting you can keep the activity active, and when the time runs out, automatically send an email to the CEO informing that it has not yet been finished, but as the timer is non-interrupting as the name itself says, it will not interrupt the activity.

Examples:

I recommend taking a look at this part of the documentation that explains well about timer events.

William Robert Alves

Can I understand it correctly that in interrupting, the lower one is executed, and in non-interrupting, both are executed? Can I, for example, set it to interrupting, so that the task is present until 5 p.m. and then it should end? Would that be possible? Thank you for your help.

Yeah!

Interrupting will “interrupt” your current task, and will only execute the task below… so if the timer task didn’t finish in time, it won’t be able to complete it anymore.

Non-interrupting will continue the progress of your current task, and also execute the task below.

As for the timer ending a task at 5 p.m, I would need to better understand what you need to do to model a good solution.

Imagine that you put a timer to end at 5 p.m on your task… if your “instance” arrives at the task at 17:01h, the task will only be closed at 5 p.m on the next day.

The timer starts “counting” from the moment the instance arrives on it, so I suggest putting a timer that sets a deadline, for example “expires after 2 hours”.

Example to configure your timer to fire after 2 hours that the instance reach on it:

image

But you can also use Cron expressions to set your timer.
This link below explains how to do it:

William Robert Alves

I wanted to create, for example, two processes. In the first process, I would like to set it up so that if the process is not resolved within 5 minutes, the task should disappear at a parallel gateway, meaning the token should be removed. In the next process, there should be a task, and if it is not resolved by 5 PM on July 11, 2023, the process should be terminated. That’s what I mean. If you want, I can show you my BPMN model.

Yes, please post your BPMN, however, you cannot put specific dates in your timers. (See post #13 above)

That’s not how parallel gateways work. In a parallel gateway, multiple tokens get created.

I fear that some of this information is getting lost through translating.

This statement doesn’t actually make sense.

I think what you are asking for is something like this. But I think you’re still missing some core BPMN concepts, and would suggest going back to the Academy Basics videos again.

1 Like

I know that the process is wrong, but I want to illustrate what I would like to do. It’s like this: I want to set it up so that Task B and Task C are available for 45 seconds each. If I complete Task B within 45 seconds and didn’t have time for Task C because its 45 seconds expired, I want the marker for Task C to disappear and only Task B to be executed. I hope it can be understood somehow.

What you have drawn here:

When the process has been requested to start, immediately do Task A.
When Task A has been completed, Do all of the following (in any order):
1 Wait 45 seconds, then do Task B
2 Wait 45 seconds, then do Task C
When all of the above are completed, then do Task D
When Task D is complete, the overall process is complete

I think what you mean to draw is:

When process is requested to start:
Immediately do Task A
When Task A is completed, do all of the following (in any order):
1 Do Task B
2 Do Task C
(Once all of the above are complete) OR ( If the above tasks are not completed within 45 seconds - Stop doing them ) and
Do Task D
When Task D is complete, the overall process is complete.

In my process, Task B and C should be within the same branch. If Task B is executed within 45 seconds but Task C is not, then it proceeds to Task D even though Task C was not executed because the timer has already expired