0

I'm working on a system that implements multiple microservices which communicate via a RabbitMQ messaging bus.

  • These microservices are created using python with the pika library (to publish messages as well as consume a RabbitMQ queue)
  • One of these microservices (let's call it 'orders') has a connected database to store data

So far, the application components are asynchronous relying fully on RabbitMQ exchanges/queues for communication and, when needed, implements callback queues when one microservice needs to request data from another.

Now that I have backend microservices talking to each other, I would like to implement a RESTful API interface for this 'orders' microservice so clients (ex: web browsers, external applications) can receive and send data.

I can think of two ways to do this:

  1. Create another microservice (let's call it 'orders-api') in something like flask and have it connected to the underlying database behind the 'orders' microservice. This seems like a bad idea since it breaks the microservice pattern to only have a database connected to a single microservice (I don't want two microserices having to know about the same data model)

  2. Create an 'api-gateway' microservice which exposes a RESTful API and, when receiving a request, requests information from the 'orders' microservice via the messaging bus. Similar to how RabbitMQ documents Remote Procedure Calls here: https://www.rabbitmq.com/tutorials/tutorial-six-python.html. This would mean that the 'api-gateway' would be synchronous, and thus, would block while waiting for a response on the messaging bus.

I'm not sure if there are other ways to achieve this which I'm not familiar with. Any suggestions on how to integrated a RESTful API in this environment would be appreciated!

2
  • Greetings. You've done a good job summarizing your question. Also, this is more of an architectural question than a technology specific question. You might consider posting this to the Software Engineering stackexchange. Commented Jan 22, 2020 at 4:06
  • Thanks for the information! That seems like a more appropriate place. I'll post this over there as well! Commented Jan 22, 2020 at 4:32

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.