IBM Websphere MQ 基础4:Channel通道与MQ间消息传输

article/2025/9/27 3:41:16

概念

WebSphere® MQ uses two different types of channels:

  • A message channel, which is a unidirectional communications link between two queue managers. WebSphere MQ uses message channels to transfer messages between the queue managers. To send messages in both directions, you must define a channel for each direction.

消息通道,一种两个QM之间的无向通信连接。WebSphere MQ通过消息通道在队列管理器之间传输信息。

  • An MQI channel, which is bidirectional and connects an application (MQI client) to a queue manager on a server machine. WebSphere MQ uses MQI channels to transfer MQI calls and responses between MQI clients and queue managers.

MQI通道,一种双向的、提供MQI客户端到QM的连接的通道。WebSphere MQ利用MQI通道传输MQI调用,并为MQI-clientQM之间的通信提供服务。

When referring to message channels, the word channel is often used as a synonym for a channel definition. It is usually clear from the context whether we are talking about a complete channel, which has two ends, or a channel definition, which has only one end.

Message channels

Message channel definitions can be one of the following types:

Message channel definition type

Description

Sender

发送通道

A sender channel is a message channel that the queue manager uses to send messages to other queue managers. To send messages using a sender channel, you must also create, on the other queue manager, a receiver channel with the same name as the sender channel. You can also use sender channels with requester channels if you are implementing a "callback" mechanism.

发送通道用于一个QM发送消息至另外一个QM,接收MQ必须创建与发送QM同名的接收通道。也可以同时使用请求通道和发送通道实现回调机制。

Server

服务器通道

A server channel is a message channel that the queue manager uses to send messages to other queue managers. To send messages using a server channel, you must also create, on the other queue manager, a receiver channel with the same name as the server channel. You can also use server channels with requester channels. In that case, the requester channel definition at the other end of the channel requests the server channel definition to start. The server sends messages to the requester. The server can also initiate the communication as long as the server knows the connection name of the partner channel.

服务通道用于一个QM发送消息至另外一个QM,接收MQ必须创建与发送QM同名的接收通道。

Receiver

接收者通道

A receiver channel is a message channel that the queue manager uses to receive messages from other queue managers. To receive messages using a receiver channel, you must also create, on the other queue manager, a sender or a server channel with the same name as this receiver channel.

Requester

请求者通道

A requester channel is a message channel that the queue manager uses to send messages to other queue managers. To send messages using a requester channel, you must also create, on the other queue manager, a sender channel if you are implementing a callback mechanism, or a server channel.

Cluster-sender

A cluster-sender (CLUSSDR) channel definition defines the sending end of a channel on which a cluster queue manager can send cluster information to one of the full repositories. The cluster-sender channel is used to notify the repository of any changes to the queue manager's status, for example the addition or removal of a queue. It is also used to transmit messages. The full repository queue managers themselves have cluster-sender channels that point to each other. They use them to communicate cluster status changes to each other. It is of little importance which full repository a queue manager's CLUSSDR channel definition points to. After the initial contact has been made, further cluster queue manager objects are defined automatically as required so that the queue manager can send cluster information to every full repository, and messages to every queue manager. For more information, see Queue manager clusters.

Cluster-receiver

A cluster-receiver (CLUSRCVR) channel definition defines the receiving end of a channel on which a cluster queue manager can receive messages from other queue managers in the cluster. A cluster-receiver channel can also carry information about the cluster—information destined for the repository. By defining the cluster-receiver channel, the queue manager indicates to the other cluster queue managers that it is available to receive messages. You need at least one cluster-receiver channel for each cluster queue manager. For more information, see Queue manager clusters.

For each channel you must define both ends so that you have a channel definition for each end of the channel. The two ends of the channel must be compatible types.

You can have the following combinations of channel definitions:

  • Sender–Receiver
  • Server–Receiver
  • Requester–Server
  • Requester–Sender (callback)
  • Cluster-sender–Cluster-receiver

Message channel agents(MCA)

Each channel definition that you create belongs to a particular queue manager. A queue manager can have several channels of the same or different types. At each end of the channel is a program, the message channel agent (MCA). At one end of the channel, the caller MCA takes messages from the transmission queue and sends them through the channel. At the other end of the channel, the responder MCA receives the messages and delivers them to the remote queue manager.

通道的两端是一个称为MCA(消息通道代理)的程序。Caller MCA(通道的一端)从传输队列中获取消息并通过通道发送,(responder MCA)通道的另一端结束消息并将其派发到远端队列管理器。

A caller MCA can be associated with a sender, server, or requester channel. A responder MCA can be associated with any type of message channel.

caller MCA能与senderserverrequester通道关联,responseer MCA能与任何类型的消息通道关联。

WebSphere MQ supports the following combinations of channel types at the two ends of a connection:

WebSphere MQ所支持的通道类型组合如下:

Caller

Direction of message flow

Responder

Channel type

Listener required?

 

Listener required?

Channel type

Sender

No

Caller to Responder

Yes

Receiver

Server

No

Caller to Responder

Yes

Receiver

Server

No

Caller to Responder

Yes

Requester

Requester

No

Responder to Caller

Yes

Server

Requester

Yes

Responder to Caller

Yes

Sender

MQI channels

MQI channels can be one of the following types:

MQI通道有两种类型:

MQI channel type

Description

Server connection

服务器连接

A server connection channel is a bidirectional MQI channel that is used to connect a WebSphere MQ client to a WebSphere MQ server. The server connection channel is the server end of the channel.

服务器连接通道是一种用于连接WebSphere MQ clientWebSphere MQ server的双向MQI通道,是服务器端的连接通道。

Client connection

A client connection channel is a bidirectional MQI channel that is used to connect a WebSphere MQ client to a WebSphere MQ server. WebSphere MQ Explorer also uses client connections to connect to remote queue managers. The client connection channel is the client end of the channel. When you create a client-connection channel, a file is created on the computer that hosts the queue manager. You must then, copy the client-connection file to the WebSphere MQ Client computer.

客户端连接通道是一种用于连接WebSphere MQ clientWebSphere MQ server的双向MQI通道。WebSphere MQ Explorer也是应用客户端连接通道去连接远程QM,是客户端的连接通道。

一个完整的例子(配置QM将消息发送远程QM)

架构图:

架构图:

QM_ZAVIER                              ---->>                      QM_ZAVIER2

QM_APPLE(本地队列)                                   Q1(本地队列)

Q1(远程队列)

第一阶段:发送队列管理器与监听器创建/启动

  1. 创建发送QM
    crtmqm -q QM_ZAVIER
  2. 启动发送QM
    strmqm QM_ZAVIER
  3. 创建监听器
    runmqsc QM_ZAVIER
    def listener(LISTENER.ZAVIER) trptype(tcp) control(qmgr) port(1417)
  4. 启动监听器
    start LISTENER(LISTENER.ZAVIER)

第二阶段:发送端本地队列/远程队列创建

  1. 运行命令行
    runmqsc QM_ZAVIER
  2. 创建本地队列QM_APPLE
    define qlocal(QM_APPLE) usage(xmitq)
    说明:usage表示队列用法,填normal代表本地队列,填xmitq代表传输队列
  3. 创建远程队列
    define qremote (Q1) rname (Q1) rqmname(QM_ZAVIER2) XMITQ(QM_APPLE)
    其中:
    qremote:是在本地QM(QM_ZAVIER)创建的归属于远程QM(QM_ZAVIER2)远程队列定义;
    rname:是远程QM(QM_ZAVIER2)中的本地队列;
    rqmname:是远程QM名;
    XMITQ:本地队列管理器用来将消息发送至远程队列管理器的传输队列的名称。本例中为填QM_APPLE

第三阶段:接收队列管理器的创建/启动、接收队列

  1. 创建接收管理器
    crtmqm -q QM_ZAVIER2
  2. 启动接收管理器
    strmqm QM_ZAVIER2
  3. 创建并启动监听器
    runmqsc QM_ZAVIER2
    def listener(LISTENER.ZAVIER2) trptype(tcp) control(qmgr) port(1418)
    start LISTENER(LISTENER.ZAVIER2)
  4. 创建接收端的本地队列(测试表明:接收端usage(xmitq)不需要)
    define qlocal(Q1) usage(xmitq)

第四阶段:双方通道的创建

  1. 接收端通道
    define channel(ZAVIER.ZAVIER2) chltype (RCVR) trptype (TCP)
  2. 发送端通道
    define channel(ZAVIER.ZAVIER2) chltype (sdr) conname ('127.0.0.1(1418)') xmitq(QM_APPLE) trptype(tcp)
  3. 启动发送端通道
    start channel(ZAVIER.ZAVIER2)

注意:

  • 发送端、接收端通道名必须相同;
  • chltype表示通道类型。RCVR表示Receiversdr表示Sender,还有SVR(server)、SVRCONN(server-connection)、CKYSSDR(cluster-sender)等。具体可选值有以下集中:

SDR | SVR | RCVR | RQSTR | CLNTCONN | SVRCONN | CLUSSDR | CLUSRCVR | MQTT*

  • conname表示连接名,格式为:computer_name(port_number),其中,computer_name 是托管该目标队列管理器的计算机的名称或 IP 地址,port_number 是该目标队列管理器的侦听器正在使用的端口。--接收端IP地址与监听端口;
  • xmitq:传输队列名
  • trptype:传输协议类型

测试

1. 发送端amqsput

2. 接收端amqsget

注意:用amqsget、amqsput测试时需要区分大小写(在队列管理器的runmqsc界面下不用区分),因为这是在Linux视图下。

参考:

IBM Websphere MQ _02 MQ消息队列、通道、消息的创建及传输

 


http://chatgpt.dhexx.cn/article/mcr7p4E2.shtml

相关文章

MQ - 如何保证消息不丢失?处理重复消息?消息堆积处理?

什么是消息队列 在百度百科中,消息队列是这么解释的:“消息队列”是在消息的传输过程中保存消息的容器。 消息队列全称为英文 Message Queue 简称(MQ)是一种应用程序对应用程序的通信方法。MQ 是消费-生产者模型的一个典型的代表…

IBM MQ通道常用知识列举(一)

MQ的几个基本组件: 1. 什么是通道 通道是分布式队列管理器在IBM MQ MQI 客户端和IBM MQ服务器之间或两个IBM MQ服务器之间使用的逻辑通信链路。通道用于将消息从一个队列管理器移动到另一个队列管理器。 2, 启动通道 对发送方、服务器和请求方通道使用 MQSC 命令…

微服务 消息中间件MQ

微服务 消息中间件MQ 1. MQ的定义2. MQ的作用3. MQ的特点4. MQ消费方式5. 常用MQ对比分析 1. MQ的定义 MQ就是消息中间件。面向消息的中间件(message-oriented middleware)MOM能够很好的解决以上问题。是指利用高效可靠的消息传递机制与平台无关的数据交…

MQ消息队列

MQ MQ全称Message Queue(消息队列), 实在消息传输过程中保存消息的容器。多用于分布式系统之间进行通信两种 通信方式: MQ优势 消息到达MQ后直接给出响应,然后服务去消费相应的消息,用户体验极好 应用解耦:提高系…

IBMMQ linux版命令创建队列管理器、队列、通道、window连接(六)

1. 队列、通道介绍 1.1 本地队列 本地队列又分为普通本地队列和传输队列,普通本地队列是应用程序通过API对其进行读写操作的队列;传输队列可以理解为存储-转发队列,比如:我们将某个消 息交给MQ系统发送到远程主机,而此…

IBM MQ 通道

一,定义 通道是分布式队列管理器在IBM MQ MQI 客户端和IBM MQ服务器之间或两个IBM MQ服务器之间使用的逻辑通信链接。 通道是提供从一个队列管理器到另一个队列管理器的通信路径的对象。通道在分布式队列中用于将消息从一个队列管理器移动到另一个队列管理器&#x…

MQ135

这里写自定义目录标题 以MQ135为例 原文链接 首先声明,公式不是官方给定的,而且有很多的局限性。 这篇文章是个人对MQ系列传感器电压与浓度转换的公式进行一个探索。 以MQ135为例 在氨气曲线上采点,得 x(ppm)[10,2…

MQ简介以及架构图

一、什么是MQ Message Query(MQ),消息队列中间件,很多初学者认为,MQ通过消息的发送和接受来实现程序的异步和解耦,mq主要用于异步操作,这个不是mq的真正目的,只不过是mq的应用&…

IBMMQ java远程访问(四)

当应用程序和MQ不在同一台主机上的时候,我们将要通过通道去访问; 1.创建队列管理器时勾选创建服务器链接通道; 2.创建一个本地队列 命名为Q1 3.创建通道 右击通道->新建->服务器链接通道 命名为SERVERQM2 4.代码示例调用 package com.i…

MQ理论介绍与主流MQ对比

1、什么是MQ? MQ(Message Queue)消息队列,是基础数据结构中“先进先出”的一种数据结构。指把要传输的数据(消息)放在队列中,用队列机制来实现消息传递——生产者产生消息并把消息放入队列,然…

什么是MQ

MQ概述 MQ全称 Message Queue(消息队列),是在消息的传输过程中保存消息的容器。多用于分布式系统之间进 行通信。 分布式系统之间进行通信: 远程调用:各系统间直接通过远程调用的方式; 借助第三方完成系统…

MQ的概念和RabbitMQ知识点(无代码)

目录 1. MQ的基本概念 1.1 MQ概述 1.2 MQ的优势 1. 应用解耦 2. 异步提速 3. 削峰填谷 1.3 MQ的劣势以及可能引发的问题 1.4 常见的MQ产品 2. RabbitMQ的知识点 2.1 RabbitMQ的工作模式 1. 简单模式 2. 工作队列模式 Work Queue 3. 发布订阅模式 Publish/subscri…

MQ简介

一、何为MQ? MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法。应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们。消息传递指的是程序之间通…

【MQ基本概念 MQ的工作原理】

一、 MQ 基本概念 1 、 MQ 概述 MQ 全称 Message Queue (消息队列),是在消息的传输过程中保存 消息的容器。多用于分布式系统之间进 行通信。 小结 MQ ,消息 队列,存储消息的中间件 分布式系统通信两种方式&…

mq的基本介绍和基本用法

一 、什么是MQ,有什么用 MQ 是message queue ,消息队列,也叫消息中间件,遵守JMS(java message service)规范的一种软件。(同时还有另一个叫AMQP的应用层协议,语言无关性不受产品 语言等限制,r…

MQ(Message Queue)简介

一、何为MQ? MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法。应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们。消息传递指的是程序之间通…

MQ消息队列详解、四大MQ的优缺点分析

MQ消息队列详解、四大MQ的优缺点分析 前言面试题切入面试官心理分析面试题剖析①为什么要使用MQ系统解耦异步调用流量削峰消息队列的优缺点四大主流MQ(kafka、ActiveMQ、RabbitMQ、RocketMQ)各自的优缺点 前言 近期有了想跳槽的打算,所以自己…

file和filestream

在C#编程环境中,当我们对电脑文件进行读写、移动、复制、删除等这些操作时,这些都可以在system.IO名称空间下,所以当我们想要通过C#编程语言对其进行操作时,需要添加该名称空间,它内部包含对数据流和文件进行同步或异步…

java filestream_java FileStream文件流操作

直接上代码,函数使用说明详见Java API文档 import java.io.*; public class StreamDemo { public static void main(String[] args) { File fnew File("F:\\workspace\\JavaPrj\\test.txt"); FileOutputStream outnull; try { outnew FileOutputStream(f)…

c#FileStream文件读写

//C#文件流写文件,默认追加FileMode.Append string msg "okffffffffffffffff"; byte[] myByte System.Text.Encoding.UTF8.GetBytes(msg); using (FileStream fsWrite new FileStream("D:\1.txt", FileMode.Append)) {fsWrite.Write(myByte, 0, myByte.…