Hello,
How can we set the timer date through Java code ? Can we use an expression on the timer event and then we set the value via execution variable ?
Thanks
Hello,
How can we set the timer date through Java code ? Can we use an expression on the timer event and then we set the value via execution variable ?
Thanks
Hi @Soumi,
You can use expression which includes execution variables but once the expression gets evaluated, a timer job is created and changing values of the variables has no affect.
If there is a need to change the date after the job is created then you need to explicitly set due date of the created job to a new date value.
Hello @hassang
That’s how I configure the timer and I set the value like this : delegateExecution.setVariable(“timervalue”,“2022-06-04T09:45:00”);
Unfornately I’m having the following error :
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.JobEntity.updateTimer (batch index #3) failed. 2 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: Batch entry 0 update ACT_RU_JOB
SET REV_ = 64,
EXECUTION_ID_ = '5fe66601-e3ea-11ec-9088-fcb3bc607fe9',
LOCK_EXP_TIME_ = NULL,
LOCK_OWNER_ = NULL,
RETRIES_ = 2,
EXCEPTION_STACK_ID_ = '08885e94-e41a-11ec-9088-fcb3bc607fe9',
EXCEPTION_MSG_ = 'ENGINE-09027 Exception while resolving duedate '''': Invalid format: ""',
FAILED_ACT_ID_ = 'Event_0rvllxy',
DUEDATE_ = '2022-06-04 09:45:00+04',
REPEAT_ = NULL,
REPEAT_OFFSET_ = 0,
SUSPENSION_STATE_ = 1,
PROCESS_DEF_ID_ = 'testEcheance:6:596eaaa3-e3ea-11ec-9088-fcb3bc607fe9',
PROCESS_DEF_KEY_ = 'testEcheance',
JOB_DEF_ID_ = '596eaaa4-e3ea-11ec-9088-fcb3bc607fe9',
DEPLOYMENT_ID_ = '596c39a1-e3ea-11ec-9088-fcb3bc607fe9',
HANDLER_CFG_ = 'Event_1w7629p',
PRIORITY_ = 0,
SEQUENCE_COUNTER_ = 2,
LAST_FAILURE_LOG_ID_ = '08881073-e41a-11ec-9088-fcb3bc607fe9'
where ID_= '5fe66603-e3ea-11ec-9088-fcb3bc607fe9'
and REV_ = 63 was aborted: ERROR: column "last_failure_log_id_" of relation "act_ru_job" does not exist
Position: 542 Call getNextException to see other errors in the batch.
### Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.JobEntity.updateTimer (batch index #3) failed. 2 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: Batch entry 0 update ACT_RU_JOB
SET REV_ = 64,
EXECUTION_ID_ = '5fe66601-e3ea-11ec-9088-fcb3bc607fe9',
LOCK_EXP_TIME_ = NULL,
LOCK_OWNER_ = NULL,
RETRIES_ = 2,
EXCEPTION_STACK_ID_ = '08885e94-e41a-11ec-9088-fcb3bc607fe9',
EXCEPTION_MSG_ = 'ENGINE-09027 Exception while resolving duedate '''': Invalid format: ""',
FAILED_ACT_ID_ = 'Event_0rvllxy',
DUEDATE_ = '2022-06-04 09:45:00+04',
REPEAT_ = NULL,
REPEAT_OFFSET_ = 0,
SUSPENSION_STATE_ = 1,
PROCESS_DEF_ID_ = 'testEcheance:6:596eaaa3-e3ea-11ec-9088-fcb3bc607fe9',
PROCESS_DEF_KEY_ = 'testEcheance',
JOB_DEF_ID_ = '596eaaa4-e3ea-11ec-9088-fcb3bc607fe9',
DEPLOYMENT_ID_ = '596c39a1-e3ea-11ec-9088-fcb3bc607fe9',
HANDLER_CFG_ = 'Event_1w7629p',
PRIORITY_ = 0,
SEQUENCE_COUNTER_ = 2,
LAST_FAILURE_LOG_ID_ = '08881073-e41a-11ec-9088-fcb3bc607fe9'
where ID_= '5fe66603-e3ea-11ec-9088-fcb3bc607fe9'
and REV_ = 63 was aborted: ERROR: column "last_failure_log_id_" of relation "act_ru_job" does not exist
Position: 542 Call getNextException to see other errors in the batch.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:254)
at org.camunda.bpm.engine.impl.db.sql.DbSqlSession.flushBatchOperations(DbSqlSession.java:444)
at org.camunda.bpm.engine.impl.db.sql.BatchDbSqlSession.executeDbOperations(BatchDbSqlSession.java:74)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:341)
... 19 common frames omitted
Caused by: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.JobEntity.updateTimer (batch index #3) failed. 2 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: Batch entry 0 update ACT_RU_JOB
SET REV_ = 64,
EXECUTION_ID_ = '5fe66601-e3ea-11ec-9088-fcb3bc607fe9',
LOCK_EXP_TIME_ = NULL,
LOCK_OWNER_ = NULL,
RETRIES_ = 2,
EXCEPTION_STACK_ID_ = '08885e94-e41a-11ec-9088-fcb3bc607fe9',
EXCEPTION_MSG_ = 'ENGINE-09027 Exception while resolving duedate '''': Invalid format: ""',
FAILED_ACT_ID_ = 'Event_0rvllxy',
DUEDATE_ = '2022-06-04 09:45:00+04',
REPEAT_ = NULL,
REPEAT_OFFSET_ = 0,
SUSPENSION_STATE_ = 1,
PROCESS_DEF_ID_ = 'testEcheance:6:596eaaa3-e3ea-11ec-9088-fcb3bc607fe9',
PROCESS_DEF_KEY_ = 'testEcheance',
JOB_DEF_ID_ = '596eaaa4-e3ea-11ec-9088-fcb3bc607fe9',
DEPLOYMENT_ID_ = '596c39a1-e3ea-11ec-9088-fcb3bc607fe9',
HANDLER_CFG_ = 'Event_1w7629p',
PRIORITY_ = 0,
SEQUENCE_COUNTER_ = 2,
LAST_FAILURE_LOG_ID_ = '08881073-e41a-11ec-9088-fcb3bc607fe9'
where ID_= '5fe66603-e3ea-11ec-9088-fcb3bc607fe9'
and REV_ = 63 was aborted: ERROR: column "last_failure_log_id_" of relation "act_ru_job" does not exist
Position: 542 Call getNextException to see other errors in the batch.
at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:149)
at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:129)
at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:122)
at org.apache.ibatis.executor.CachingExecutor.flushStatements(CachingExecutor.java:114)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:252)
... 22 common frames omitted
Can you please advise? Is it the correct way to write the expression : ${timervalue} ?
Thanks
Hi @Soumi,
I did a simple test.
Kindly find attached a simplified working model. It worked properly.
Your issue looks like a database issue. Have you done an upgrade to your Camunda platform?
test_timer_mi_process.bpmn (5.1 KB)
Hello @Soumi ,
which version of Camunda Platform do you use? Could it be that the database this log comes from was created in an older version?
From what I see, a column seems to be missing from a table.
If so, please make sure the database schema version fits the Platform Version.
Jonathan
Hello @hassang @jonathan.lukas
Yes I did an upgrade from community version 7.16.0 to enterprise version 7.17.0. Should I drop all tables and re-create it with the version enterprise ?
Hello @Soumi ,
if the data is not required, you can definitely do this.
Anyway, ee and ce have the same db dchema
Jonathan
Hi @Soumi,
Please follow the below docs
And more specifically this link for updating database scheme manually
Ok I drop all the tables and re-create it. It’s working now.
However I have another concern.
Based on the above workflow, I’m defining an array in the service task P0 :
-List<TaskInfo> taskInfos = Arrays.asList(new TaskInfo("1","100","2022-06-06T06:45:00"),
new TaskInfo("2","100","2022-06-06T08:45:00"));
delegateExecution.setVariable("taskInfoList", taskInfos);
As you can see, the third element in the array is a Date and I’m passing this array to the SubProcess (Sequential Multiinstance). How can I configure the timer such that it can retrieve the date from the array (taskInfos) ? Normally , the data from the taskInfos will be used in the subprocess by the timer (3rd element from taskInfos ) and P1 (1st and 2nd element from taskInfos )
Hello @Soumi ,
if you have Spin installed and you use serialization format application/json, the expression will be ${S(taskInfo).prop(time)}
The S function will transform your Java Object into a json node that can be traversed
Jonathan
Hello @jonathan.lukas
Do we have spin for camunda enterprise 7.17.0?
Hello @Soumi ,
of course you have. Spin is an open-source project that requires no extra licensing. You will need two dependencies for an embedded engine:
If you are using the spring-boot-starter, the plugin is picked up and installed automatically.
The property for the default serialization format is an engine configuration that can be made in the application.yaml in case of spring-boot.
Jonathan
I add the following dependency in pom.xml :
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-plugin-spin</artifactId>
<version>7.17.0-ee</version>
</dependency>
And I got the following error :
**The process could not be started.** **:** Cannot instantiate process definition testEcheance:10:3b8f3943-e502-11ec-84b9-fcb3bc607fe9: Error while evaluating expression: ${S(TaskInfo).prop(date)}. Cause: Error invoking function 'S'
I’m using Springboot.
Did I miss anything?
Hello @Soumi ,
please consider adding the preffered serialization dependency (json-jackson)
Do you have an example please?
Hello @Soumi ,
not at the moment, but maybe @Niall has an example about how to use Spin to traverse a json node in an expression and using the right dependencies.
Jonathan
Thanks all for your help. I will create a new topic regarding the camunda spin