Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

262
Views
Handling Sync API call (REST/Spring) and Async message (Kafka) in the same execution

I've a usecase to respond to an API call to the client that should happen in Sync. But within the api execution, the system A need to publish a kafka message to an different system B and system B returns response to System A which it consumes and should respond to the client as API response.

So, here this problem has Async pub-sub model and also Sync API handling. I can handle the pub-sub with producer and consumer as two diffrent @Async methods, but finding a problem in correlating both within Sync execution.

The main thread that was spawn by API can wait for consumer to get respond, but that becomes blocking thread.

Any suggestions on implementing this highly appreciated.

Thanks

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You didn't say what programming language the sync and the async parts are written in but in general you should use the Async Request Response pattern described in the EIP book here http://www.enterpriseintegrationpatterns.com/patterns/conversation/RequestResponse.html

The app that is handling the sync API (such as a REST API call over HTTP) would publish to a request topic, including in the request message a unique CorrelationID (that you generate in your app) and then at the other end, your Async app can processes these requests from the request topic, and reply to a response topic using the CorrelationID as a Key and/or including it in the response messages (so the original requestor knows which response to correlate to which request).

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!