Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

265
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda