如何通过 .Net Core 中的 AMQP API 连接到 IBM MQ

How can I connect to IBM MQ via the AMQP API in .Net Core

我正在使用“AMQPNetLite.Core”连接到 IBM MQ 服务器。

但是,当我尝试建立新连接时,抛出了 OperationCanceledException。

Address address = new Address($"amqp://{hostName}:{port}");
// System.OperationCanceledException: 'The transport 'TcpTransport' is closed.'
Connection connection = new Connection(address, SaslProfile.Anonymous, null, null);
Session session = new Session(connection);

IBM MQ 服务器中的日志显示:

The data received from host 'xxx.xxx.xxx.xxx' on channel '????' is not valid. [CommentInsert1(xxx.xxx.xxx.xxx), CommentInsert2(TCP/IP), CommentInsert3(????)]
The TCP/IP responder program encountered an error. [CommentInsert1(TCP/IP), CommentInsert3(xxx.xxx.xxx.xxx)]

频道是“????”在日志中,这是否意味着我需要在实例化连接之前指定一个通道?但是我在哪里可以这样做呢?地址和连接 类 似乎没有地方可以指定频道名称。

服务器应该正常工作,因为我可以通过“IBMMQDotnetClient”发送和接收消息

MQEnvironment.Hostname = hostName;
MQEnvironment.Channel = channel;
MQQueueManager queueManager = new MQQueueManager(queueManagerName);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue system_default_local_queue = queueManager.AccessQueue(queueName, openOptions);
// Send and Receive message via the queue

根据评论,您似乎还没有设置 AMQP 服务。

本教程的第 1 步 - https://developer.ibm.com/tutorials/mq-running-ibm-mq-apps-on-quarkus-and-graalvm-using-qpid-amqp-jms-classes/#step-1-set-up-the-amqp-channel-in-ibm-mq

展示了如何设置 AMQP 侦听器。我们有更多的 AMQP 教程正在准备中,该步骤可能很快就会在其自己的文章中结束,但教程将继续指向它。

**注意:**教程要求你克隆

git clone -b 9.2.3 ...

目前最新的是9.2.5即

git clone -b 9.2.5 ...

关键的子步骤是:

Enable AMQP in the MQ container by editing the install-mq.sh file, and changing the following AMQP line to:

Export genmqpkg_incamqp=1

Set up AMQP authority, channel, and service properties by adding the contents of the add-dev.mqsc.tpl file to the bottom of the /incubating/mqadvanced-server-dev/10-dev.mqsc.tpl file in your cloned repository.