Timer definition Camunda flyway problem Spring boot

Hello @Niall

I have a spring boot application and in the yaml file I added
image

and in Camunda Process:
image

The problem is when I want to change this value of the timer from the yaml file. When I start the application for first time then flyway generates the DB and then if I stop the application and change the timer with another one and start again the application the timer is not updated but if I stop the application again and add the option for flyway:
image

then it will delete the DB and it will take the new timer value that I have in the yml file of my spring boot application.

Do you have any idea how can I make this to work without to make flyway to clean the DB whenever I start the application?

Hi @dawdaw_dawdaw

I am not sure I understand what you are trying to do here. Could you explain your use case?

BR
Michael

Hi @mimaom sure, I want to be able to change the time from the yml file.
Once I deploy the app the yml file and everything is generated in the DB like processors from Camunda etc…
If I stop the application and if I do not reset the DB and after that If I start the application again with changed timer in the yml file then the timer (cronjob) is not updated. It will work with the old cronJob added for the timer.

Is it more clear now?

Hi @dawdaw_dawdaw

What DB do you mean? Camunda DB or your own custom DB?

BR
Michael

Hello @dawdaw_dawdaw ,

the reason is that the timer is determined once by the engine, at job creation time, and then not changed again.

Timers are handled by Jobs in the engine. A job has a due date that is calculated and set by the timer event. This date could be modified during runtime to trigger the job at another point in time.

Maybe this information helps

Jonathan

@jonathan.lukas Thank you for the answer, can you please provide some more information maybe some link?

I am not sure how to do that, actually at the end of the day what I want is the value from the yml file will be directly modified from the Kubernates configuration. But I think if I manage to work it in the way you mentioned then it should work fine also via the Kubernates configuration.

Hello @dawdaw_dawdaw ,

I will provide you something. But first, I would like to know whether the requirement really is to change already existing timers?

The timer event is made to be set only once (when the token arrives).

Jonathan

@jonathan.lukas
Hi Jonathan,
We have Testing environment with Kubernates and we dont want to stop and deploy the application but the existing variable from the yaml file of Spring boot can be overwriten in Kubernates deployment files and I can build one listener which will check when the variable is changed then update the timer in the Camunda Job. This is just to improve our working process so we dont use that much time to stop redeploy the whole application etc., the code will not be used in Production environment. So the answer is yes, we want in runtime to change the existing timer.

This is the solution:

	ManagementService managementService = execution.getProcessEngineServices().getManagementService();

		CronTrigger trigger = new CronTrigger(example5minLater);
		TriggerContext context = new TriggerContext() {

			public Date lastScheduledExecutionTime() {
				return null;
			}

			public Date lastActualExecutionTime() {
				return null;
			}

			public Date lastCompletionTime() {
				return null;
			}
		};

		final Date date = trigger.nextExecutionTime(context);
		final List<Job> jobList = managementService.createJobQuery().processDefinitionId(execution.getProcessDefinitionId()).timers().list();
		for (Job job : jobList) {
			managementService.setJobDuedate(job.getId(), date);
		}

Hello @dawdaw_dawdaw ,

this looks really good. Does it work? :slight_smile:

Jonathan

This problem is not new, it has been discussed here in one or two forum threads – with solutions. Just use the search facility. There is also one or more tickets in camunda’s Jira system about this, but I assume they are busy working on camunda 8, hence tickets for camunda 7 must wait longer (if not forever).

yes it works very good

1 Like