Creating a simple queue manager in Java

Registries are created in Java™ by using the class com.ibm.mqe.MQeQueueManagerConfigure. An instance of this class is created, and activated by passing it some initialization parameters. The parameters are supplied in the form of an MQeFields object. Within this MQeFields are contained two sub fields, one holding information about the registry, and one holding information about the queue manager being created. As we are creating a very simple queue manager, we only need to pass two parameters, the queue manager name, in the queue manager parameters, and the registry location, in the registry parameters. We can then use the MQeQueue ManagerConfigure to create the standard queues.

First, create three fields objects, one for the QueueManager parameters, one for the Registry parameters. The third fields object, parms, is used to contain both the QueueManager and Registry fields objects.
MQeFields parms = new MQeFields();
MQeFields queueManagerParameters = new MQeFields();
MQeFields registryParameters = new MQeFields();
The QueueManager name needs to be set. Use the MQeQueueManager.Name as the Field Label constant.
queueManagerParameters.putAscii(MQeQueueManager.Name, queueManagerName); 
The location of the persistent registry needs to be specified. Do this in the Registry Parameters field object. Use the MQeRegistry.DirName as the Field Label constant.
registryParameters.putAscii(MQeRegistry.DirName, registryLocation); 
The QueueManager and registry parameters can now be embedded in the main fields object.
parms.putFields(MQeQueueManager.QueueManager, queueManagerParameters);
parms.putFields(MQeQueueManager.Registry, registryParameters);
An instance of MQeQueueManagerConfigure can be created now. This needs the parameters fields object, plus a String identifying the details of the queue store to use.
MQeQueueManagerConfigure qmConfig = 
new MQeQueueManagerConfigure(parms, queueStore);
The four common types of queues can now be created via four convenience methods as follows:
qmConfig.defineQueueManager();
qmConfig.defineDefaultSystemQueue();
qmConfig.defineDefaultDeadLetterQueue();
qmConfig.defineDefaultAdminReplyQueue();
qmConfig.defineDefaultAdminQueue();
Finally the MQeQueueManagerConfigure object can be closed.
qmConfig.close();

Terms of use | WebSphere software

(c) Copyright IBM Corporation 2004, 2005. All rights reserved.