Use connection property override in IBM MQ classes for JMS

If a connection factory is created programmatically, and it is not possible to modify the source code for the application that creates it, then the connection override functionality can be used to change the properties that the connection factory uses when a connection is created. However, the use of the connection override functionality with connection factories defined in JNDI is not supported.


In the IBM MQ classes for JMS, details about how to connect to a queue manager are stored in a connection factory. Connection factories can either be defined administratively and stored in a JNDI repository, or created programmatically by an application by using Java API calls.

If an application creates a connection factory programmatically, and it is not possible to modify the source code for that application, the connection override functionality allows you to override the connection factory properties in the short term. In the long term, though, we must put plans in place to allow the connection factory used by the application to be modified without using the connection override functionality.

If the connection factory that is created programmatically by an application is defined to use a Client Channel Definition Table (CCDT), then the information in the CCDT is used in preference to the overridden properties. If the connection details that the application uses need to be changed, then a new version of the CCDT must be created and made available to the application.

The use of the connection override functionality with connection factories defined in JNDI is not supported. If an application uses a connection factory that is defined in JNDI, and the properties of that connection factory need to be changed, then the definition of the connection factory must be updated in JNDI. Although the connection override functionality is applied to these connection factories (and the overridden properties take precedence over the properties in the connection factory definition that is looked up in JNDI), this use of the connection override functionality is not supported.

Important: The connection override functionality affects all of the applications that are running inside of a Java runtime environment, and applies to all of the connection factories used by those applications. It is not possible to just override properties for individual connection factories or applications.

When an application uses a connection factory to create a connection to a queue manager, the IBM MQ classes for JMS look at the properties that have been overridden and use those property values when creating the connection, rather than the values for the same properties in the connection factory.

For example, suppose a connection factory has been defined with the PORT property set to 1414. If the connection override functionality has been used to set the PORT property to 1420, then when the connection factory is used to create a connection, the IBM MQ classes for JMS use a value of 1420 for the PORT property, rather than 1414.

To modify any of the connection properties that are used when creating a JMS connection from a connection factory, the following steps need to be carried out:
  1. Add the properties to be overridden to an IBM MQ classes for JMS configuration file.
  2. Enable the connection override functionality.
  3. Start the application, specifying the configuration file.


Procedure

  1. Add the properties to be overridden to an IBM MQ classes for JMS configuration file.
    1. Create a file containing the properties and values that need to be overridden in the standard Java properties format. For details about how you create a properties file, see The IBM MQ classes for JMS configuration file.
    2. To override a property, add an entry to the properties file. Any IBM MQ classes for JMS connection factory property can be overridden. Add each required entry in the following format:
      jmscf.property name=value
      

      where property name is the JMS administration property name or XMSC constant for the property that needs to be overridden. For a list of connection factory properties, see Properties of IBM MQ classes for JMS objects.

    For example, to set the name of the channel that an application should use to connect to a queue manager, we can add the following entry to the properties file:

    jmscf.channel=MY.NEW.SVRCONN
    
  2. Enable the connection override functionality. To enable connection override, set the com.ibm.msg.client.jms.overrideConnectionFactory property to be true so that the properties that are specified in the properties file are used to override the values that are specified in the application. We can either set the extra property as another property in the configuration file itself, or pass the property as a Java system property by using:
    -Dcom.ibm.msg.client.jms.overrideConnectionFactory=true
    
  3. Start the application, specifying the configuration file. Pass the properties file that you created to the application at run time by setting the Java system property:
    -Dcom.ibm.msg.client.config.location 
    
    Note that the location of the configuration file must be specified as a URI, for example:
    -Dcom.ibm.msg.client.config.location=file:///jms/jms.config
    


Results

When the connection override functionality is enabled, the IBM MQ classes for JMS write an entry to the jms log whenever a connection is made. The information in the log shows the connection factory properties that were overridden when the connection was created, as shown in the following example entry:
Overriding ConnectionFactory properties:
          Overriding property channel: 
                Original value = MY.OLD.SVRCONN 
                New value      = MY.NEW.SVRCONN
Parent topic: Use IBM MQ connection property override


Related tasks


Related information