Dynamic TPName support at runtime

About this task

BTT provides the dynamic TP Name support function to help you to change the LU62 TP name of the connection factory dynamically if required.

You can specify the TP name for a connection factory when you define the custom property of connection factory in WebSphere® Application Server console. But this fixed TP name must be used for all the connections of the WAS connection factory.

The dynamic TPname support function enables you to make one WAS connection factory to support multiple LU62 TPs and to change the TP name dynamically upon the application connection request. The JCA LU62 looks for an existing free connection with the same TP name from the pool of the connection factory first. If no free connection for the requested TP name is found, the JCA LU62 connection factory will create a new connection for the TP name in the pool. If the maximum connection limitation of the connection factory pool is reached, the JCA LU62 will look for a free connection with a different tpName, and change the tpName of the free connection to the requested TP name. To change the tpName of the connection, the JCA LU62 conversation of the connection will be re-established.

To use the dynamic TPName support function, set the MaxConnections properties for the connection factory in the Custom Property of WAS J2C configuration. This property should match the value set in the WAS pool parameter of the connection factory. You need to call the method setTpName(Stirng tpName) of class Lu62ConnectionSpec and set Lu62ConnectionSpec instance as input parameter for connectionFactory.getConnection, then you can get a connection from pool for the specified TP.

The following is the sample code to get connection with a specific tpName from WAS pool/connection factory:
public Connection getLu62Connection( String tpName)  throws NamingException, ResourceException{
      
	InitialContext initialContext = new javax.naming.InitialContext();
      ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup((jndiName);  
	Lu62ConnectionSpec lu62ConnectionSpec = new Lu62ConnectionSpec();
	lu62ConnectionSpec.setUserName("userJCA");
	lu62ConnectionSpec.setPassword("passwordJCA");
	lu62ConnectionSpec.setTpName(tpName);	    	
      Connection  cxn = connectionFactory.getConnection(lu62ConnectionSpec);  
      return cxn ;
 }

Results

What to do next