Migrate Camunda 7 JavaDelegate and ExecutionListener beans to Camunda 8 job workers
ProprietaryTurns a class that implements org.camunda.bpm.engine.delegate.JavaDelegate into a Spring bean with a @JobWorker method that takes an io.camunda.client.api.response.ActivatedJob. The job type is the bean name, which is what Camunda's Diagram Converter makes of camunda:delegateExpression="${beanName}" and of camunda:class. Variables are read from the job, and the variables the delegate set are returned from the method, so that the job completes with them. A private method the execution is passed on to takes the job instead, and the map of variables to set when it sets any. Camunda 8 keeps variables as JSON, so a variable read as a type that JSON has to be converted to, such as Long, a date or a class of the application, becomes a @Variable parameter, which the Spring SDK converts. A removed variable is set to null, since Camunda 8 can't remove one. A job has its element's id but not its name, so the activity name in a log message becomes the element id. BpmnErrors become CamundaError.bpmnError(..). A delegate whose DelegateExecution is used in a way Camunda 8 has no counterpart for, such as reaching the process engine, reading a variable after setting it, passing the execution on to another class or to a method other classes can call, or whose execute method is called directly by other code, is left unchanged and listed in the Camunda7CodeNotMigrated data table. An ExecutionListener's notify method becomes a job worker the same way, since Camunda 8 runs execution listeners as jobs. Its job type is the bean name of a Spring bean and the fully qualified class name otherwise, which is what the Diagram Converter makes of camunda:delegateExpression and of camunda:class on an execution listener. A listener that throws a BpmnError, which Camunda 8 does not support for execution listeners, is left unchanged.
io. moderne. camunda. camunda8. MigrateJavaDelegateToJobWorkermod run . --recipe= io. moderne. camunda. camunda8. MigrateJavaDelegateToJobWorkerInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.