How to get the process cron schedule with java api

1
0
-1

Hello,

lest's suppose I've a process deployed that is scheduled to run every X (days or months, etc).

Is there any java api that I can use to get X?

Thank you

2 answers

1
+1
-1
This one is the BEST answer!

Hi Enrico,

You are perfectly right, the API method searchTimerEventTriggerInstances() takes a processInstanceId as a parameter, so it means that it only applies to timers linked to a process instance, that is to say, intermediate timers, boundary timers, and event-subprocess start timers.

For normal start timers, they are not linked to a specific instance, as they are defined on a process definition to trigger the creation of instances.
To retrieve them, you need to retrieve the process definition and inspect the start timers and their start condition:

ProcessManagementAPI.getDesignProcessDefinition().getFlowElementContainer().getStartEvents() ...

Hope this helps (better this time ;-)

1
0
-1

Hi Enrico,

You simply have to call the Engine Java method :

org.bonitasoft.engine.api.ProcessRuntimeAPI#searchTimerEventTriggerInstances()

See class TimerEventTriggerInstanceSearchDescriptor for the search options capabilities.

Hope this helps

Comments

Submitted by enrico.curiotto on Thu, 08/26/2021 - 15:29

Thank you. I want to know the duration of a start event. I did the following test:

Start a simple process with a timer (duration 1 minute) and human task; Retrieve the processInstanceId from the portal; Execute programmatically the query you suggested;

I don't get any results for my start timer. I guess it's logic I think the start event is archived at the moment.

Is there any way to workaround that? I don't see any searchARCHIVEDTimerEventTriggerInstances() in the api... Thanks

Submitted by emmanuel.duchas... on Thu, 08/26/2021 - 16:54

Have you tried search for EventInstance "name"?

Submitted by enrico.curiotto on Thu, 08/26/2021 - 17:39

Yes, with searchOptions.filter(TimerEventTriggerInstanceSearchDescriptor.EVENT_INSTANCE_NAME, "Start Timer");

Start timer events are not detected.

If I update the process adding a timer event "Timer2" after the human task, and I run the search before this timer is activated, then I find it correctly.

Notifications