This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ZeebeInboundConnector(name = "io.camunda.community:amqp:1") | |
public class AmqpInboundSubscription implements SubscriptionInboundConnector { | |
@Override | |
public void activate(InboundConnectorConfig config, InboundConnectorContext context) throws Exception { | |
initialize(context, config.getConfiguredParameters()); | |
consumerTemplate = createConsumerTemplate(); | |
consumerTemplate.start(); | |
while (running) { | |
Exchange receive = consumerTemplate.receive( getParameters().getEndpointUri() ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ZeebeOutboundConnector( | |
name = "http-json", | |
taskType = "io.camunda:http-json:1", | |
variablesToFetch = {"restUrl", "username","password", "..."}) | |
public class RestOutboundConnectorFunction implements OutboundConnectorFunction { | |
//... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HttpJsonFunction implements OutboundConnectorFunction { | |
@Override | |
public Object execute(OutboundConnectorContext context) { | |
final var json = context.getVariables(); | |
final var request = GSON.fromJson(json, HttpJsonRequest.class); | |
final var validator = new Validator(); | |
request.validate(validator); | |
validator.validate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class MapDmnResult implements ExecutionListener { | |
@Override | |
public void notify(DelegateExecution execution) throws Exception { | |
List<String> risks = new ArrayList<String>(); | |
Set<String> riskLevels = new HashSet<String>(); | |
Object oDMNresult = execution.getVariable("riskDMNresult"); | |
for (Object oResult : (List<?>) oDMNresult) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
public class OrderFulfillmentRestController { | |
@Autowired | |
private ProcessEngine camunda; | |
@RequestMapping(path = "/order", method = PUT) | |
public String placeOrder(String orderPayload, HttpServletResponse response) throws Exception { | |
// TODO: Somehow extract data from orderPayload | |
String orderData = "todo"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class CreateCustomerInCrmJavaDelegate implements JavaDelegate { | |
@Autowired | |
private ObjectMapper objectMapper; | |
@Autowired | |
private CrmFacade crmFacade; | |
public void execute(DelegateExecution execution) throws Exception { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ZeebeWorker(type = "payment", autoComplete = true) | |
public Map<String, Object> retrievePayment(ActivatedJob job) { | |
// some work | |
// any exception thrown here will lead to retrying/incidents in Zeebe | |
if (successful) { | |
// some data is returned to be stored as process variable | |
return variables; | |
} else { | |
// problem shall be indicated to the process and can be handled via BPMN error events | |
throw new ZeebeBpmnError("DOESNT_WORK", "This does not work because..."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JobWorker(type = "payment") | |
public void retrievePayment(ActivatedJob job) { | |
// Do whatever you need to, e.g. invoke a remote service | |
String orderId = job.getVariablesMap().get("orderId"); | |
paymentRestClient.invoke(...); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Transactional | |
public void paymentReceived(...) { | |
// ... | |
paymentRepository.save( payment ); | |
orderService.markOrderPaid( payment.getOrderId(), payment.getId() ); | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static async void BlockingJobHandler(IJobClient jobClient, IJob activatedJob) | |
{ | |
Log.LogInformation("Invoke REST call..."); | |
var response = httpClient.GetAsync("/").Result; | |
Log.LogInformation("...finished. Complete Job..."); | |
await jobClient.NewCompleteJobCommand(activatedJob).Send(); | |
counter.inc(); | |
} |