Runtime tools : Service components : JCA SNA Connector : JCA SNA LU62 Connector : Tasks : JCA LU62 sample code : Dynamic TPName support at runtime
  
Dynamic TPName support at runtime
UDTT 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 ;
}
Receive Timeout Exception
When the receiving of data is timed out, JCA LU62 Connector will throw out exception, instead of returning empty message. Besides, when the JCA LU62 Connector receives error return code from API calling of the Communication Server, it will also throw out exception. The exception is javax.resource.ResourceException. The detailed information of session and return code is wrapped in the exception. The application catches the exception and close the interaction and connection.
Multiple Segments Message Receiving
JCA LU 62 Connector supports multiple segments message receiving by two ways:
If the number of multiple segments message is fixed, the application can call SYNC_RECEIVE verb as many times as the number of the multiple segments message.
If the number of multiple segments message is not fixed, the application can use SYNC_SEND_RECEIVE verb. By using this verb, the host application can change the conversation state of host side from SEND to other states to notify the JCA LU62 Connector that the multiple segments message is ended.
Go up to
JCA LU62 sample code