To place a message in IBM MQ from AX, we can use the library from IBM Bus, i.e., amqmdnet.
Create a Visual Studio project with the below code and add to AOT.
Hashtable connectionProperties = new Hashtable();
connectionProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
connectionProperties.Add(MQC.HOST_NAME_PROPERTY, Connectionname);
connectionProperties.Add(MQC.CHANNEL_PROPERTY, Channel);
MQQueueManager queueManager = new MQQueueManager(QueueManager, connectionProperties);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue queue = queueManager.AccessQueue(QueueName, openOptions);
MQMessage queueMessage = new MQMessage();
queueMessage.CharacterSet = 1208;
queueMessage.WriteBytes(message);
MQPutMessageOptions queuePutMessageOptions = new MQPutMessageOptions();
queue.Put(queueMessage, queuePutMessageOptions);
Call the above code from X++ and pass the message, queue manager details to place the message in IBM MQ.
Create a Visual Studio project with the below code and add to AOT.
Hashtable connectionProperties = new Hashtable();
connectionProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
connectionProperties.Add(MQC.HOST_NAME_PROPERTY, Connectionname);
connectionProperties.Add(MQC.CHANNEL_PROPERTY, Channel);
MQQueueManager queueManager = new MQQueueManager(QueueManager, connectionProperties);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue queue = queueManager.AccessQueue(QueueName, openOptions);
MQMessage queueMessage = new MQMessage();
queueMessage.CharacterSet = 1208;
queueMessage.WriteBytes(message);
MQPutMessageOptions queuePutMessageOptions = new MQPutMessageOptions();
queue.Put(queueMessage, queuePutMessageOptions);
Call the above code from X++ and pass the message, queue manager details to place the message in IBM MQ.
No comments:
Post a Comment