Hello, this might be a silly question but I haven’t been able to find an answer to it anywhere.
I am using Camunda 8 Cloud with my Spring Boot Application and need to write several @ZeebeWorker functions for the service tasks in these diagrams. All the examples I have seen whether it be on YouTube or GitHub show the ZeebeWorker functions being written within the main application class (the one tagged with @SpringApplication) like so:
package com.mycompany.camunda;
// dependencies
@SpringBootApplication
@EnableZeebeClient
@Slf4j
public class CamundaApplication {
public static void main(String[] args) {
SpringApplication.run(CamundaApplication.class, args);
}
@ZeebeWorker(type="job-a")
public void handleJobA(final JobClient client, final ActivatedJob job) {
log.info("Job A is executing");
client.newCompleteCommand(job.getKey())
.variables("{\"JSONKey\": \"JSONValue\"}")
.send()
.exceptionally(throwable -> { throw new RuntimeException("Could not complete job " + job, throwable); });
}
}
However, I do not want to write all of my all of my ZeebeWorker in this class. I want to be able to group related Worker functions classes in varying modules like this:
package com.mycompany.camunda.worker;
// Dependencies
@Slf4j
@EnableZeebeClient
public class CallActivity {
@ZeebeWorker(type="job-b")
public void handleJobB(final JobClient client, final ActivatedJob job) {
log.info("Job A is executing");
client.newCompleteCommand(job.getKey())
.variables("{\"JSONKey\": \"JSONValue\"}")
.send()
.exceptionally(throwable -> { throw new RuntimeException("Could not complete job " + job, throwable); });
}
}
When I do this, they don’t appear to be found by the ZeebeWorkerAnnotationProcessor.
So, how do I write ZeebeWorker functions outside of the @SpringApplication class?