Search code examples
javaibm-mq

Creating IBM queue programmatically in java


How can you create a new queue programmatically using the MQQueueManager and MQQueue objects?

Is there a guide on how to use these classes? The javadocs don't say much.


Solution

  • To create a dynamic queue, you just open a model queue. The dynamic queue is created and you get back a handle to it. The name of the queue is provided as well and you can place that in the Reply-To-Queue field of a request message.

    If you want to create a permanent queue, have a look at com.ibm.mq.pcf in the Infocenter. To execute any WMQ admin command from an application, submit a Programmable Command Format (PCF) message to the SYSTEM.ADMIN.COMMAND.QUEUE. The application must be authorized to put a message onto the queue for this to work. Furthermore, the command server will use the user ID in the message header to look up authorizations for the specific command being executed. To create a queue, the submitter must have +crt authority on queues.

    Note that any person or app with the ability to create a permanent queue is a defacto administrator. If their ID is not authorized to create authorization control list entries, they need only to create an alias over the command queue and can then spoof the administrative user ID. For this reason, it is rare that any non-administrator would be granted rights to create queues.