...
try (final ZeebeClient client = clientBuilder.build()) {
final Order order = new Order();
order.setOrderId(31243);
client
.newCreateInstanceCommand()
.bpmnProcessId("demoProcess")
.latestVersion()
.variables(order)
.send()
.join();
client.newWorker().jobType("foo").handler(new DemoJobHandler()).open();
waitUntilSystemInput("exit");
}
}
public static class Order {
private long orderId;
private double totalPrice;
public long getOrderId() {
return orderId;
}
public void setOrderId(final long orderId) {
this.orderId = orderId;
}
public double getTotalPrice() {
return totalPrice;
}
public void setTotalPrice(final double totalPrice) {
this.totalPrice = totalPrice;
}
}
private static class DemoJobHandler implements JobHandler {
@Override
public void handle(final JobClient client, final ActivatedJob job) {
final Order order = job.getVariablesAsType(Order.class);
System.out.println("new job with orderId: " + order.getOrderId());
order.setTotalPrice(46.50);
client.newCompleteCommand(job.getKey()).variables(order).send();
}
}