Java JMS 使用哪种协议来发送和接收消息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23882032/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Which protocol does JMS use to send and receive messages?
提问by Shenoy
I want to know if JMS API uses any protocol to transfer messages or if uses its own. If the former, which protocol?
我想知道 JMS API 是使用任何协议来传输消息还是使用自己的协议。如果是前者,哪种协议?
I have read many articles over the net but I couldn't find an answer for this.
我在网上阅读了很多文章,但我找不到答案。
采纳答案by Isaac
The standard JMS API is merely a set of interfaces; JMS providers (such as WebSphere MQ) provide their own implementations for these interfaces.
标准的 JMS API 只是一组接口;JMS 提供者(例如 WebSphere MQ)为这些接口提供它们自己的实现。
The only thing that you can say for sure about all JMS implementations is that they all adhere to the JMS API; other than that, a JMS implementation may use any protocol whatsoever in order to fulfill the JMS API contracts.
对于所有 JMS 实现,您唯一可以确定的是它们都遵循 JMS API;除此之外,JMS 实现可以使用任何协议来实现 JMS API 契约。
Now, when you're asking specifically about "protocols", you should also define which "layer" in the communication you are referring to (have a look at the OSI Model, for example). When your JMS client has to talk to a JMS server that is located on another machine on the network (a typical case), the protocol used between the client and the server will be based, in one way or another, on TCP/IP. Over the wire, you'll be able to see TCP/IP packets being exchanged back and forth.
现在,当您专门询问“协议”时,您还应该定义您所指的通信中的哪个“层”(例如,查看OSI 模型)。当您的 JMS 客户端必须与位于网络上另一台机器上的 JMS 服务器通信时(典型情况),客户端和服务器之间使用的协议将以某种方式基于 TCP/IP。通过网络,您将能够看到来回交换的 TCP/IP 数据包。
At the higher level, there are no guarantees; you are likely to find proprietary protocols varying between different implementors. Remember that, with JMS, performance is often crucial; JMS vendors put a lot of efforts into ensuring that their protocols ("above" TCP/IP) perform well. HTTP, for example, won't do.
在更高级别,没有任何保证;您可能会发现专有协议在不同的实现者之间有所不同。请记住,对于 JMS,性能通常是至关重要的;JMS 供应商付出了很多努力来确保他们的协议(“高于”TCP/IP)运行良好。例如,HTTP 就不行。
回答by Aniket Thakur
There is no protocol as such that is mentioned in the JMS specs. It is purely dependent on the JMS provider and his approach to offer efficiency and security.One thing that er can be sure of is that whatever protocol provider uses to communicate between server and client will be built upon the TCP/IP protocol(Transport layer). You may have HTTP which is an application layer protocol or if the provider provides it you may have SSL which is a Presentation layer protocol.
JMS 规范中没有提到这样的协议。它完全依赖于 JMS 提供者及其提供效率和安全性的方法。可以确定的一件事是,任何协议提供者用于服务器和客户端之间的通信都将建立在 TCP/IP 协议(传输层)上. 您可能拥有 HTTP,它是一种应用层协议,或者如果提供商提供它,您可能拥有 SSL,它是一种表示层协议。
For example ActiveMQ supports following protocols
例如 ActiveMQ 支持以下协议
- AMQP
- List item
- MQTT
- OpenWire
- REST
- RSS and Atom
- Stomp
- WSIF
- WS Notification
- XMPP
- AMQP
- 项目清单
- MQTT
- 开放线
- 休息
- RSS 和原子
- 跺脚
- WSIF
- WS 通知
- XMPP
More details here.
更多细节在这里。
回答by Siva
It uses AMQP protocol. You can use JMS to do 1-to-1 communication using Message Queue provided by Middleware. If you want to send 1-to-many using JMS, the middleware provides Topic. Both of them use binary format in a bit stream at least in IBM MQ.
它使用 AMQP 协议。您可以使用 JMS 使用 Middleware 提供的 Message Queue 进行一对一通信。如果你想使用 JMS 发送一对多,中间件提供了 Topic。至少在 IBM MQ 中,它们都在位流中使用二进制格式。