Creating and configuring connection factories and destinations in an IBM MQ classes for JMS application

An IBM® MQ classes for JMS application can create connection factories and destinations by retrieving them as administered objects from a Java Naming and Directory Interface (JNDI) namespace, by using the IBM JMS extensions, or by using the IBM MQ JMS extensions. An application can also use the IBM JMS extensions or IBM MQ JMS extensions to set the properties of connection factories and destinations.

Connection factories and destinations are starting points in the flow of logic of a JMS application. An application uses a ConnectionFactory object to create a connection to a messaging server, and uses a Queue or Topic object as a target to send messages to or a source from which to receive messages. An application therefore needs to create at least one connection factory and one or more destinations. Having created a connection factory or destination, the application might then need to configure the object by setting one or more of its properties.

In summary, an application can create and configure connection factories and destinations in the following ways:
Using JNDI to retrieve administered objects
An administrator can use the IBM MQ JMS administration tool as described in Configuring objects using the JMS administration tool, or IBM MQ Explorer as described in Configuring JMS objects using IBM MQ Explorer, to create and configure connection factories and destinations as administered objects in a JNDI namespace. An application can then retrieve the administered objects from the JNDI namespace. Having retrieved an administered object, the application can, if required, set or change one or more of its properties by using either the IBM JMS extensions or the IBM MQ JMS extensions.
Using the IBM JMS extensions
An application can use the IBM JMS extensions to create connection factories and destinations dynamically at run time. The application first creates a JmsFactoryFactory object, and then uses methods of this object to create connection factories and destinations. Having created a connection factory or destination, the application can use methods inherited from the JmsPropertyContext interface to set its properties. Alternatively, the application can use a uniform resource identifier (URI) to specify one or more properties of a destination when it creates the destination.
Using the IBM MQ JMS extensions
An application can also use the IBM MQ JMS extensions to create connection factories and destinations dynamically at run time. The application uses the supplied constructors to create connection factories and destinations. Having created a connection factory or destination, the application can use methods of the object to set its properties. Alternatively, the application can use a URI to specify one or more properties of a destination when it creates the destination.