Reputation: 47
I have a microservice built using spring boot. The Load balancer has a fixed timeout and this service does some large calculation and thus the response gets timed out when I call it from the UI.
I figured that Spring Kafka will be very suitable in this scenario and can help me to queue my responses into kafka producer and then read them from consumer service. But the kafka topic that we create is constant for the entire service, then how can I retrieve the results back from this queue corresponding to the specific request made from the UI.(Since there will be multiple requests for the same service). Also if there is some good example for this implementation would be very helpful
Upvotes: 2
Views: 2018
Reputation: 174739
There is an open pull request to add request/reply semantics to Spring for Apache Kafka.
The sendAndReceive
method returns a ListenableFuture
which is completed when the reply is received.
Upvotes: 1
Reputation: 2740
What are you looking for are basically two things
Creating a pipeline to process all your async request.
Tracking System to track the state of your job.
So you should assign a trackingId to each request that you are pushing in Kafka queue and as the message flow through the pipeline updates the state corresponding to that trackingId. In order to know the exact status, you should expose an API (which you can link with your UI) which will give the exact status of your job.
Upvotes: 1