I wanted to create IBM queues from REST endpoint as described in documentation https://www.ibm.com/docs/en/ibm-mq/9.1?topic=applications-creating-destinations-in-jms-application
IBM version - 9.1.0.5
Queue Manager is started and listener is running
Application and IBM server are on the same host
Authorization is turned off on the server side
Connection and session is successfully created but the problem is that I'm not able to create queue directly in the server (queue is not listed in /var/mqm/qmgrs/QMGR/queues). In the application I see that the object with expected fields is created but it's not propagated to WebSphere. There is no error in AMQERR01.LOG.
Do you know what could be wrong with my configuration?
Do I need to use PCF to accomplish this?
I was trying a lot of ways to create queue (some examples below):
MQQueueConnectionFactory mqQueueConnectionFactory = new MQQueueConnectionFactory();
mqQueueConnectionFactory.setQueueManager("QMGR");
mqQueueConnectionFactory.setHostName("X.X.X.X");
mqQueueConnectionFactory.setChannel("CHANNEL.X");
mqQueueConnectionFactory.setTransportType(com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
QueueConnection queueConnection = mqQueueConnectionFactory.createQueueConnection();
QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queueSession.createQueue(name);
----------------------------------------------------------------------------------------
JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
JmsConnectionFactory cf = ff.createConnectionFactory();
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, "X.X.X.X");
cf.setIntProperty(WMQConstants.WMQ_PORT, 1414);
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, "CHANNEL.X");
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, "QMGR");
cf.setStringProperty(WMQConstants.WMQ_APPLICATIONNAME, "MQ provider");
cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, false);
JMSContext context = cf.createContext();
Destination destination = context.createQueue("queue:///" + name);
System.out.println(destination.toString());
I was able to achieve this functionality with python pymqi libray but I need to do it in Java:
import pymqi
from flask import Flask
app = Flask(__name__)
HOST = 'X.X.X.X'
PORT = '1414'
CONN_INFO = '%s(%s)' % (HOST, PORT)
QUEUE_MANAGER = 'QMGR'
@app.route('/queue/<string:channel_name>/<string:queue_name>')
def create_queue(channel_name, queue_name):
queue_type = pymqi.CMQC.MQQT_LOCAL
max_depth = 123456
args = {pymqi.CMQC.MQCA_Q_NAME: queue_name.encode('ascii'),
pymqi.CMQC.MQIA_Q_TYPE: queue_type,
pymqi.CMQC.MQIA_MAX_Q_DEPTH: max_depth}
qmgr = pymqi.connect(QUEUE_MANAGER, channel_name.encode('ascii'), CONN_INFO)
pcf = pymqi.PCFExecute(qmgr)
pcf.MQCMD_CREATE_Q(args)
qmgr.disconnect()
return "OK"
app.run(host='0.0.0.0', port=8080)
createQueueis only creating a JMS reference to an existing IBM MQ queue. You could use PCF or the REST API of MQ to create the queue on the queue manager. You could use temporary dynamic queues withcreateTemporaryQueuewhich would go away when your connection closes, that is mentioned further down the page you linked to.