MQeQueueConnectionFactory is the WebSphere MQ Everyplace implementation of the javax.jms.QueueConnectionFactory interface. It is used to generate instances of QueueConnection classes, which for WebSphere MQ Everyplace must have a reference to an active queue manager. The QueueConnectionFactory must be able to create a reference to an active queue manager in order to pass it on to the QueueConnection classes that it generates. The MQeQueueConnectionFactory class can be configured to obtain a reference to a queue manager in the following ways:
However, if neither of these options are suitable then the MQeQueueConnectionFactory class can be extended to provide the required behavior. This is discussed later in this chapter.
To configure a connection factory to start a queue manager itself, it must be given a reference to an initialization (.ini) file that contains all the information it needs to start the queue manager. The connection factory is configured using its setIniFileName() method:
(MQeQueueConnectionFactory(factory)).setIniFileName(filename);
where 'filename' is the name of the initialization file. When the connection factory has been configured with the name of the initialization file, it can either be stored in a JNDI directory, so that it can be looked up by application programs, or it can be used directly in an application program. When the connection factory generates its first QueueConnection it starts the client queue manager using the initialization file and passes a reference to the active queue manager to the QueueConnection. If it generates more QueueConnection classes, it passes them a reference to the same active queue manager. When the last QueueConnection is closed, the connection factory closes the queue manager.
To configure a connection factory to look for an existing queue manager, the initialization file name should be set to null. This is the default value when the MQeQueueConnectionFactory class is created, and it can also be set explicitly using the setIniFileName() method:
(MQeQueueConnectionFactory(factory)).setIniFileName(null);
In this case, when the connection factory generates a QueueConnection, it looks for a queue manager already running in the JVM and passes the QueueConnection a reference to it. An exception is thrown if no queue manager is running. If it generates more QueueConnection classes, it passes them a reference to the same queue manager. The connection factory does not close the queue manager when the last QueueConnection is closed.