消息通道和消息队列本身有什么区别?

时间:2015-07-31 11:43:43

标签: message-queue messaging ibm-mq mq

消息通道和消息队列本身有什么区别?

他们是不同的东西。队列实际上保存将以FIFO方式处理(推送到侦听器)的消息。

频道是传输消息的媒介。
这究竟是什么意思?在一本书“企业集成模式”中,它说:

  

使用消息通道连接应用程序,其中一个应用程序将信息写入通道,另一个应用程序从通道读取该信息。

这是否意味着此消息通道实际上将队列从消息的生产者和消费者中抽象出来?但它真的不对吗?当生产者必须将消息放入队列时,它实际上指定了它想要连接的队列管理器和队列名称。

还有通道中不同协议的概念和通道中的不同数据格式,您可能为每个协议使用单独的通道,也可能是每种数据格式(XML,JSON等)的单独通道。 这将有助于不同的队列从不同的频道中获取。但为什么不直接为不同的数据格式调用不同的队列?渠道的作用究竟是什么?这只是一种联系吗?

我是MQM的全新人物。我刚刚被分配到这个涉及制作和消费消息的项目,我正试图围绕这个问题。

3 个答案:

答案 0 :(得分:14)

To expand a bit on Shashi's answer, please keep in mind that the EIP book referenced talks about high level messaging patterns. In that context the authors needed a generic term for the medium by which messages are transferred between two points and chose the word "channel".

For purposes of the book the a channel connects any two endpoints that move messages, for any message transport vendor. In this case a channel has attributes that are classes of service and support the various patterns. It may be 1-1, 1-many, many-1, many-many, etc.

So for example if it is ZeroMQ, the endpoints are two peer-to-peer nodes and there's no messaging engine between them. For IBM MQ one endpoint is always the queue manager (a type of messaging engine) and the other is an application or another queue manager.

Based on this example, it should be obvious that channel as used in the book and channel as defined by any messaging transport are at different levels of abstraction. As used by MQ, a channel is a specific set of configuration parameters that define a communication path and includes such attributes as CONNAME, MAXMSGL, tuning parameters, SSL parameters, etc. Once an MQ channel is successfully started, you can see a running instance of it by displaying the channel status. In the case of CLUSRCVR, SVRCONN, and (less commonly) RCVR or RQSTR channels, you may see multiple instances of the same channel active simultaneously.

If you are still with me, you may have noticed that the MQ usage of the term channel always describes one or more point-to-point network connections whereas the EIP book's usage of the term channel is roughly translated as "the thing that moves messages between application endpoints." Consider that two applications connected directly to the queue manager using shared memory would be using a channel as defined in EIP but not as the term is defined by IBM MQ.

Based on that example, it should be clear that the EIP version of the term channel includes the queue manager and any MQ connections between the queue manager and application endpoints.

To sum up:

  • The EIP book's channel is all messaging infrastructure that isn't one of the application endpoints, and in an MQ context it includes the queue manager and any MQ channels.
  • The IBM MQ channel is a specific configuration defining network connectivity between the queue manager and another queue manager or a client application.

I hope this clarifies the terminology rather than confusing things further. I will update based on any comments if needed.

答案 1 :(得分:9)

消息队列存储生产者发送的消息,以便将消息传递给消费者。 信道是用于从中发送消息的媒体或通信链路 生产者排队, 排队到消费者, 或队列管理器中的一个队列到另一个队列管理器中的另一个队列。

有两种类型的渠道:

1)消息通道是两个队列管理器之间的单向通信链接。 消息通道用于在两个队列管理器之间传输消息。

2) MQI通道将应用程序(生产者或使用者)连接到服务器计算机上的队列管理器。 MQI通道是在MQ客户端应用程序和队列管理器之间传输MQ API调用和响应所必需的。

所以, 简单来说, channel是客户端应用程序和队列管理器之间(或队列管理器之间)用于发送和/或接收消息的通信介质。

MQ使用专有协议将消息从客户端应用程序传输到队列管理器和队列管理器之间。 消息中包含的数据格式无关紧要, 它可以是包括字节,XML或JSON在内的任何东西。 任何类型的数据都可以通过同一个通道发送。

希望这会有所帮助。

答案 2 :(得分:2)

WebSphere MQ队列

队列是邮件的容器。连接到承载队列的队列管理器的业务应用程序可以从队列中检索消息,也可以将消息放入队列中。队列在其可容纳的最大消息数和这些消息的最大长度方面具有有限的容量。

Reference

频道

WebSphere®MQ使用两种不同类型的渠道:

  • 消息通道,它是两个队列管理器之间的单向通信链接。 WebSphere MQ使用消息通道在队列管理器之间传输消息。要在两个方向上发送消息,您必须为每个方向定义一个通道。
  • MQI(消息队列接口)通道,它是双向的,并将应用程序(MQI客户端)连接到服务器计算机上的队列管理器。 WebSphere MQ使用MQI通道在MQI客户机和队列管理器之间传输MQI调用和响应

Reference

相关问题