Ok..So I have started studying about MQ and its purpose/usecase etc... My existing application (Web made using JSP etc..) uses RestFUL interface to communicate with a remote server and to post/receive data from the server.
We often have to deal with the connectivity of the remote server.The synchronization problem is always there..
Message sent from our end.But Remote server went down. Or vice versa.
I came across the MQ thing and found it to be reliable when delivering and receiving messages from remote server is concerned.
But again, using REST I think the entire need for MQ appears to be a bit hazy.. I am basically looking for few of the differences between MQ and RestFUL..
I read on other blog post that with the advent of increasing research in the RestFUL domain, the MQ's will slowly loose pace..
I don't have much idea about MQ so won't comment anything but surely working with RestFUL is fun.
Would appreciate if someone provides differences between using RestFUL and MQ.
One of the biggest differences is that REST implies synchronous processing while MQ is more often asynchronous. As you already mentioned, MQ is a way to decouple producer and consumer so that they don't have to be online at the same time but the system would still be functioning as a whole.
It is a set of constraints that set out how an API (application programming interface) should work. If an API is RESTful, that simply means that the API adheres to the REST architecture. Put simply, there are no differences between REST and RESTful as far as APIs are concerned. REST is the set of constraints.
RESTful APIs are the most commonly used APIs in the world of web services. They use Hypertext Transfer Protocol (HTTP) requests to create, read, update, and delete (CRUD) data. They are popular because of their simplicity, scalability, speed, and ability to handle all data types.
An API, or application programming interface, is a set of rules that define how applications or devices can connect to and communicate with each other. A REST API is an API that conforms to the design principles of the REST, or representational state transfer architectural style.
One of the biggest differences is that REST implies synchronous processing while MQ is more often asynchronous. As you already mentioned, MQ is a way to decouple producer and consumer so that they don't have to be online at the same time but the system would still be functioning as a whole. If your use case implies a low-latency response (like a user with a browser) you need synchronous semantics and in this case MQ is just a different protocol. If latency is not a concern, or there's messaging goes only in one direction MQ may be a very viable alternative. One thing MQ provides for free is load balancing (and some level of HA) on the consumer side.
REST is much more flexible in terms of client/server compatibility. You can run a REST client nearly on every platform, which is not the case with MQ. I guess, this is the reason why some people claim MQ is getting obsolete. For this reason MQ is not good for public APIs. However, for communication between two server systems MQ still remains a very good option. A unique feature of REST is that it allows you to fully mimic the WEB behavior of your resources (hypermedia), i.e. one resource contains a reference to the other and so on. MQ cannot provide anything like that.
Performance may be another concern. I cannot give any exact figures, but MQ tends to have greater throughput.
In some rare cases due to security requirements clients cannot connect directly to the server. In such cases MQ is pretty much the only way to send data to the server.
To summarize, as a rule of thumb I would use REST
MQ
Both REST and MQ enable communicate between remote systems (and local).
In a REST communication the consumer and the REST service provider should be running for a communication to succeed. It is a point to point communication.
In MQ model the producer and consumer need not be running at the same time. The producers and consumers do not interact directly. The message broker takes care of handling the messages, persisting, it etc. Both point to point and publish-subscribe models are supported. In a publish subscribe model a message can be consumed by more than one consumer.
These are just some basic points that differentiate them. There are enough posts on SO that talk about REST and MQ.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With