Timer Events - Start Timer Event with CDI Expression: error

I’m trying to use a start timer set with a dynamic value fetched from a bean.

Per the instructions I’m setting the value:

<bpmn:startEvent id=“StartEvent_1tb7wmk” name=“start retrieve servers”>
bpmn:outgoingSequenceFlow_07drwrb</bpmn:outgoing>
bpmn:timerEventDefinition
bpmn:timeCycle${timerEventDefinitions.getQueueServersTimerDefinition()}</bpmn:timeCycle>
</bpmn:timerEventDefinition>
</bpmn:startEvent>

But, Camunda just cannot seem to find the been.

Error:

2016-08-11 11:28:38,912 ERROR [org.camunda.bpm.engine.context] (ServerService Thread Pool – 96) ENGINE-16004 Exception while closing command context: Unknown property used in expression: ${timerEventDefinitions.getQueueServersTimerDefinition()}. Cause: Cannot resolve identifier ‘timerEventDefinitions’: org.camunda.bpm.engine.ProcessEngineException: Unknown property used in expression: ${timerEventDefinitions.getQueueServersTimerDefinition()}. Cause: Cannot resolve identifier ‘timerEventDefinitions’

I’m using beans across the application - no errors except for this item.

What I’ve tried:

  1. used a known working bean reference (i.e. CDI)
  2. used an application scoped bean
  3. used a singleton been

Nothing seems to work…

The method I’m referencing doesn’t even invoke (didn’t see the ‘system out’ in the log).

Is this a bug?

I’m assembling a test-case to share…(please stand by).

Sounds like this problem: https://app.camunda.com/jira/browse/CAM-3163 (assuming you use a shared engine and you make process application deployments)

Yes. I think this was fixed on a later release.

The bug isn’t fixed yet :spider:

I confirm. The bug is not fixed.

Maybe this happens because the job creation is done at main camunda app level and the process beans are not visible until the process starts ?

I’m thinking to some workaroud though:

Old cron process become a normal process with a ‘Start Message Event’. We can call it the MAIN process.
A new process (CRON) that manages the cron
- Start Event (Timer Start Event configured to start after 1 or 2 seconds from deploy)
- An Intermediate Timer Event (expressions will work at this point)
- A Intermediate message event that makes the MAIN process start
- A final End Message Event that makes the CRON process to restart (this avoids loops and a neverending process)

The problem is that I have to do it for a lot of existing processes, each one with different cron settings.

My workaround was to use the quartz/timer features built into the Apache Camel library. I’d initiate timers which then call on various components to start the process. This workaround also allows you to change timer intervals without needing to update and re-deploy process models. This being a BIG deal when promoting models through QA->Prod. Also a nice feature to just simply manage “start process” events (or any timer for that matter) as a configuration (i.e. within property files)

Thanks @garysamuelson,

I tried to avoid external tech solutions like Quartz to give users the controls even for cron bpms inside the cockpit. But your solution appears more clean than mine.

My solution had to cope with a lot of redeploys and I had to manage the killing of all old cron bpm processes.

gary, have you ruled it out? i’m really really interested! thanks!

I did end up using Quartz. But, Apache Camel provides an excellent wrapper to help with startup and setting various timers. The timer startup code is built into the Camunda project - so everything starts up accordingly.

A clustered server configuration did require some extra work to insure I didn’t end up with multiple timers firing off various duplicate events.

One of the nice features I had with using Quartz is that I could monitor the generated events desperately. And, isolating the timer “service” from the Camunda process meant that I didn’t get a process instance per each event generated.