'Redis Streams data exchange between services

I'm working on microservices with Redis Streams.

Basically, the service A is sending jobs to service B using Redis Streams (XADD). Once service B is receiving a job through Redis Streams, this service execute an HTTP request to an external API, parse the result and XACK the job. During this time service A is waiting for data coming from service B.

What is the right way to send the parsed result of the HTTP request from service B to service A which is waiting for data ?

Possible answers I think about:

  • Use another Redis Streams (XREAD or XREADGROUP) on service A which is waiting for incomming data sent from B but I need to provide a stream name where to sent data into the message sent from A to B.
  • Use another Redis data type like lists which can use blocking requests (BLPOP, BRPOP...) but how to know if the data comming into this list is the right message ? Maybe I need to use a unique ID somewhere.
  • Use pub/sub but I don't really like this solution as there is no history or persistent data.

I hope I was clear enough.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source