Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda