本文介绍了RESTful v / s MQ。差异和其他关键功能,除了保证的交付的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好..因此,我已经开始研究MQ及其目的/用例等...
我现有的应用程序(使用JSP等制作的Web。)使用RestFUL接口与远程服务器进行通信并发布/从服务器接收数据。

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.

我遇到了MQ事情,发现从远程服务器发送和接收消息时它是可靠的。

I came across the MQ thing and found it to be reliable when delivering and receiving messages from remote server is concerned.

但是,再次使用REST,我认为对MQ的全部需求似乎有点朦胧。.
我基本上是在寻找MQ和RestFUL之间的区别。.

我在其他博客上读到,随着 RestFUL领域研究的不断增加,MQ的步伐将逐渐放慢。

I read on other blog post that with the advent of increasing research in the RestFUL domain, the MQ's will slowly loose pace..

我对MQ不太了解,因此不会发表任何评论,但肯定与RestFUL一起工作很有趣。

I don't have much idea about MQ so won't comment anything but surely working with RestFUL is fun.

如果有人提供使用RestFUL和MQ的区别,将不胜感激。

Would appreciate if someone provides differences between using RestFUL and MQ.

推荐答案

最大的区别之一是REST意味着同步处理,而MQ通常是异步的。正如您已经提到的,MQ是使生产者和消费者脱钩的一种方法,这样他们不必同时处于在线状态,但是系统仍然可以整体运行。如果您的用例暗示了低延迟响应(例如使用浏览器的用户),则需要同步语义,在这种情况下,MQ只是一个不同的协议。如果不必担心延迟,或者消息传递仅在一个方向上进行,那么MQ可能是一种非常可行的选择。 MQ免费提供的一件事是使用者方面的负载平衡(以及某种程度的HA)。

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在客户端/服务器兼容性方面更加灵活。您几乎可以在每个平台上运行REST客户端,而MQ并非如此。我想,这就是为什么某些人声称MQ已过时的原因。因此,MQ不适合公共API。但是,对于两个服务器系统之间的通信,MQ仍然是一个很好的选择。
REST的独特功能是,它可以让您完全模仿资源(超媒体)的WEB行为,即一个资源包含对另一个资源的引用,依此类推。 MQ无法提供类似的功能。

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.

性能可能是另一个问题。我无法给出确切的数字,但是MQ往往具有更高的吞吐量。

Performance may be another concern. I cannot give any exact figures, but MQ tends to have greater throughput.

在极少数情况下,由于安全性要求,客户端无法直接连接到服务器。在这种情况下,MQ几乎是将数据发送到服务器的唯一方法。

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.

总而言之,根据经验,我将使用REST

To summarize, as a rule of thumb I would use REST


  • 用于公共API或

  • 需要同步处理的地方

MQ


  • 仅涉及有限数量的服务器端系统,并且$ li $ b
  • 可接受异步处理,或者

  • REST性能不够

这篇关于RESTful v / s MQ。差异和其他关键功能,除了保证的交付的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 03:44