'How can I connect to IBM MQ via the AMQP API in .Net Core
I am using "AMQPNetLite.Core" to connect to the IBM MQ server.
However, when I try to new the connection there is an OperationCanceledException thrown.
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);
The log in IBM MQ server shows:
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)]
The channel is "????" in the log, does it mean I need to specify a channel before I instantiate a connection? But where can I do so? There seems no place at the Address and Connection classes to specify the channel name.
The server should be working, because I can send and receive message by the "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
Solution 1:[1]
Based on the comments, it looks like you haven't set up the AMQP service.
Step 1 in this tutorial - 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
shows how to set up the AMQP listener. We have more AMQP tutorials in the pipeline, and that step might soon end up in its own article, but the tutorials will continue to point at it.
**Note: ** The tutorial asks you to clone
git clone -b 9.2.3 ...
The current latest is 9.2.5 ie.
git clone -b 9.2.5 ...
The key substeps are:
Enable AMQP in the MQ container by editing the install-mq.sh file, and changing the following AMQP line to:
Export genmqpkg_incamqp=1
and
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | chughts |