Hello, im relatively new to camunda,
i am trying to use camunda as an orchestrator of microservices, data transfer is carried out through the kafka message broker.
I have a java delegate that extends AbstractBpmnActivityBehavior.
Inside the delegate, I form a message and send it through kafka to the external system (microservice listening that message).
If an error has occurred in the external system, it comes back to the orchestrator and I create an incident programmatically like this:
@KafkaHandler
public void taskHandler(@Header(KafkaHeaders.RECEIVED_TOPIC) String topic, Message message) {
try {
if (message.hasError()) {
runtimeService.createIncident(Incident.FAILED_JOB_HANDLER_TYPE, message.getExecutionId, message.getErrorMessage());
return;
}
}
....
}
The problem is that with this approach, I can’t do retry in the cockpit (org. camunda.bpm. engine.ProcessEngineException: No job found with id). Probably, i can write my own custom api to make a retry of the incident, but I would like it work in the cockpit.
Do you have any suggestions or recommendations on how to fix this? I’ll be very appreciated.
As the communication between send message and receive another message in kafka will be async, your send message job will already be completed when you receive the response message, and so maybe you cant retry it as you expected.
I think you will need to model your bpmn to better suit your needs, having activities for each step like send message, receive message and an exclusive gateway leading foward or to Send message again in the scenario you want to retry, like this example:
Note that i used a parallel gateway to have Send and Receive message at the same time, because if you have Send Message and Receive Message as sequential tasks, if the external application answer it too fast, you’ll receive some messages before the Receive Message activity is ready.
So you need to put Send and Receive message in a parallel gateway, and have only your Send Message with “Async before” and “Receive Message” NOT Async before. This way youll be sure that the Receive message activity will be commited to database and Exists before your Send Message executes. I would put “Async After” in the Receve Message activity too, so you dont loose any messages in an eventual exception in your next activities.
1 Like
Thanks for the answer! I’ll try your suggestion.