skip to Main Content

I welcome everyone. I’m trying to understand microservice architecture.

The task such: is 2 services. The first – for example, books rooms in a hotel. The second is something like a console interface that sends a booking task to the first and waits for a response from him, saying that the room is booked or not.

For this task, I chose redis as the message broker and database. But here’s the problem:

To add a room reservation task, for example, you can use list. But… How can the second interface service get the booking result? Booked or not?

What is the best way to use in this situation? It seems like stream also fits here. Or.. pub/sub. But the thing is that both services must both read the channel and write to it, and as I read, the stream is only needed to record any tasks. What is the best way to do this?

Thank you all in advance!

2

Answers


  1. There are 2 services named serviceA and serviceB

    • serviceA – books room in a hotel or returns the information that if a
      room is booked or not
    • ServiceB – is a console which sends request to serviceA for
      getting the reservation info or booking

    Pub/sub will not be suitable for this use case because pub/sub does not return any thing, publisher generates a message and subscriber consumes the message. it does not return any thing

    whereas RESTapis will be good solution e.g. serviceB will send an api request to serviceA which will return the result in response.

    Login or Signup to reply.
  2. Hello CrazyProgrammerist,

    The answer given by Abdul seems to fit this scenario.

    On top of it, I think you are moving along the correct lines.
    Why you stopped at implementing the single queue over here?

    What I suggest is using two queues over here.

    The idea is console application will send the message of booking details to the message queue.
    your first application can process this booking and send the relevant result on the second queue (call it the result queue), now console service can read this result message again and act accordingly.

    Hope this helps. Thanks.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search