Search code examples
restapiesbmessagebroker

REST APIs and messaging


I have a system that exposes a REST API with a rich set of CRUD endpoints to manage different resources. The REST API is used also by a front-end application that executes calls by using Ajax.

I would like to make some of these calls asynchronous and add reliability.

The obvious choice seems a message broker (ActiveMQ, RabbitMQ, etc...).

Never used message brokers before and I am wondering if they can be "put in front of" the REST API without having to rewrite them.

I do not want to access the REST API only through the messaging system: for some endpoints, a call must always be synchronous and the reliability is less important (mainly because in case of error the user receives an immediate feedback).

Would a full ESB be a better option for this use case?


Solution

  • If I understand your question, you would like to "register" an API endpoint as a subscriber so that it could receive the messages sent to a given queue.

    I do not think that a message broker can be configured to do this.

    For example, if you want to use a message broker, both your producers and subscribers need to use the JMS API.

    I do not know if a solution can be to implement a subscriber that will execute the corresponding API call. In this case, the reliability is compromised because the message will be dequeued before the API call is executed. It can make sense if the subscriber is running in the same process of the API, but in this case it is not clear why you should use a REST API instead of a library.