I am new to Flowable. Basically, I am creating a simple process which performs the followings service tasks (async jobs):
START → fare calculation → wallet deduction → generate passes → close order call → END
In each of the delegate service, I need to perform some interaction with a 3rd party system through kafka messaging. Once we receive data, we validate it before passing to the next delegate.
For example, in the wallet deduction service we are producing kafka event to the 3rd party and 3rd party sends success/failure. If failure we retry 3 times before pushing to dead letter. If success go to next service - pass generation.
So, we have written some Synchronous Kafka reply templates in Spring Boot as follows:
class WalletPayment implements JavaDelegate {
public void execute(DelegateExecution execution) {
…
…
RequestReplyFuture<String, String, String> sendAndReceive = replyKafkaTemplate.sendAndReceive(record, Duration.ofSeconds(timeoutInSec));
SendResult<String, String> sendResult = sendAndReceive.getSendFuture().get(); // Need to make this async
if(validate(sendResult)){
execution.setStatus(“status”, “PAID”); // proceed pass generation task…
}else{
throw new RuntimeException(); // causes retry
}
…
…
}
}
This is simple and Kafka messaging is just synchronous.
Here we need to wait till we get a reply and also prone to suffer timeout. We want to make Kafka to interact async. It can increase no. of threads in the application at runtime.
Problem is I am not getting how to make kafka async here so that the process instance stops once producer produces data async way and process instance resumes back when the consumer receives the event. Can anyone help me what is the preferred approach here ?
Environment:
Spring Boot, kafka version 2, Flowable 6.5.0
Thanks in advance.