forked from camunda/camunda-platform
/
MyWorker.java
31 lines (23 loc) · 1002 Bytes
/
MyWorker.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package org.example.camunda.process.solution.worker;
import io.camunda.zeebe.spring.client.annotation.JobWorker;
import io.camunda.zeebe.spring.client.annotation.VariablesAsType;
import org.example.camunda.process.solution.ProcessVariables;
import org.example.camunda.process.solution.service.MyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
public class MyWorker {
private static final Logger LOG = LoggerFactory.getLogger(MyWorker.class);
private final MyService myService;
public MyWorker(MyService myService) {
this.myService = myService;
}
@JobWorker
public ProcessVariables invokeMyService(@VariablesAsType ProcessVariables variables) {
LOG.info("Invoking myService with variables: " + variables);
boolean result = myService.myOperation(variables.getBusinessKey());
return new ProcessVariables()
.setResult(result); // new object to avoid sending unchanged variables
}
}