Runtime components : Service components : JCA SNA Connector : JCA SNA LU62 Connector : Tasks
  
Tasks
See also
JCA LU62 sample code
Installing the SNA JCA LU62 Connector on WebSphere Application Server
JCA SNA LU62 Connector
JCA LU62 sample code
The application can call the CCI interface to send and/or to receive message synchronously. By using the MDB that implements the Lu62MessageListener type, the application can also receive unsolicited Inbound message asynchronously. The Connector also provides a way to send outbound message by using a special CCI verb ASYNC_SEND_RECEIVE, and then receive the message asynchronously in MDB.
See also
Using CCI Interface for Outbound Communication
Using Inbound Interface for Incoming message
Dynamic TPName support at runtime
Tasks
Using CCI Interface for Outbound Communication
You can call Lu62InteractionSpec.setInteractionVerb to set the verb of the interaction:
Lu62InteractionSpec Verbs
 
Verb
Description
SYNC_SEND
Calls the Lu62Conversation.sendAndPrepareToReceive(inputMessage) method
SYNC_SEND_RECEIVE
Calls the Lu62Conversation.sendReceiveSYNC(inputMessage, timeout).getDataReceived() method
ASYNC_SEND_RECEIVE
Sends data and then receives data asynchronously in MDB. Calls the Lu62Conversation.sendAndPrepareToReceive(inputMessage) method
SYNC_RECEIVE
Calls the Lu62Conversation.readData(timeout).getDataReceived() method
SYNC_TERMINATE
Calls the Lu62Conversation.terminate() method to terminate the connection . This verb should only be used in unmanaged Environment. In WAS managed environment, the Connection.close() method should be called instead of calling SYNC_TERMINATE verb.
SYNC_GET_LOCAL_LU_NAME
Calls the CPIC_Extract_Local_LU_Name API of Communication Server to get the actual local LU name for the current conversation
SYNC_GET_PARTNER_LU_NAME
Calls the CPIC_Extract_Partner_LU_Name API of Communication Server to get the actual local LU name for the current conversation
SYNC_GET_CONVERSATION_STATUS
Calls the Lu62Conversation.getConversationStatus() to get the conversation status
Lu62InteractionSpec Timeout
You can call Lu62InteractionSpec.setExecutionTimeout to set the timeout property for receiving message.
Sample code using CCI
Connection cxn=null;
Interaction ixn=null;
try{
// get the connectionFactory by JNDI lookup:
InitialContext initialContext = new javax.naming.InitialContext();
connectionFactory = (ConnectionFactory) initialContext.lookup("snalu62");
//If you are using JCA security, pass the user name and password.
Lu62ConnectionSpec lu62ConnectionSpec = new Lu62ConnectionSpec();
lu62ConnectionSpec.setUserName("sna");
lu62ConnectionSpec.setPassword("sna");
Connection cxn = connectionFactory.getConnection(lu62ConnectionSpec);
//If you are not using JCA security, you can just get the connection:
// // // cxn = connectionFactory.getConnection();
//Set up the conversation:
ixn= cxn.createInteraction();
Lu62InteractionSpec ixnSpec = new Lu62InteractionSpec();
Lu62Record outgoingData = new Lu62Record();
Lu62Record returnData = new Lu62Record();
//Create the outgoing request message and send it:
ixnSpec.setInteractionVerb(ixnSpec.SYNC_SEND);
outgoingData.setData(requestData);
ixn.execute(ixnSpec, outgoingData, null);
//Set up to receive the response message:
ixnSpec.setInteractionVerb(ixnSpec.SYNC_RECEIVE);
ixnSpec.setExecutionTimeout(500);
ixn.execute(ixnSpec, null, returnData);
}catch (javax.resource.ResourceException e){
// handle the exception
}finally{
//close the interaction and connection
if (ixn!=null) ixn.close();
if (cxn!=null) cxn.close();
}
See also
JCA LU62 sample code
Using Inbound Interface for Incoming message
By using MDB, the application can get the information of the arrival of inbound message. The MDB implements Lu62MessageListener interface and specifies the messaging-type and activation-config-property attributes in deployment descriptor of MDB.
The following is an example:
Deployment descriptor of example MDB
<message-driven id="MDBtest2">
  <ejb-name>MDBtest2</ejb-name>
  <ejb-class>ejbs.MDBtest2Bean</ejb-class>
  <messaging-type>
    com.ibm.connector2.sna.lu62.Lu62MessageListener
  </messaging-type>
  <transaction-type>Container</transaction-type>
  <message-destination-type>javax.jms.Queue</message-destination-type>
  <activation-config>
    <activation-config-property>
      <activation-config-property-name>outgoing</activation-config-property-name>
      <activation-config-property-value>false</activation-config-property-value>
    </activation-config-property>
    <activation-config-property>
      <activation-config-property-name>tpName</activation-config-property-name>
      <activation-config-property-value>TPCDL</activation-config-property-value>
    </activation-config-property>
  </activity-config>
</message-driven>
MDB bean class
public class MDBtest2Bean implements
javax.ejb.MessageDrivenBean,
com.ibm.connector2.sna.lu62.Lu62MessageListener {
  ...
  public int onIncomingMessage(String msg, Lu62Conversation conversation) {
  // add the application implementation of handling the inbound message here
  // handling the message
  //send reply message back
  conversation.send(replyMessage);
  }
...
}
Note MDB is anonymous in nature. Therefore, it cannot be directly invoked by a client like session bean or entity bean. When the inbound message comes in, the LU62 Connector will deliver the message to message endpoint, and the onIncomingMessage method will be called by application server.
Inbound Communication for outbound reply message
The outbound message is sent by CCI verb ASYNC_SEND_RECEIVE, and the replied inbound message is received in MDB.
Following is the deployment descriptor of an example MDB:
<message-driven id="MDBtest2">
<ejb-name>MDBtest2</ejb-name>
<ejb-class>ejbs.MDBtest2Bean</ejb-class>
<messaging-type>
com.ibm.connector2.sna.lu62.Lu62MessageListener
</messaging-type>
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>outgoing</activation-config-property-name>
<activation-config-property-value>true</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>symbolicDestinationName</activation-config-property-name>
<activation-config-property-value>DSCCRIS0</activation-config-property-value>
</activation-config-property>
</activity-config>
</message-driven>
Note The outgoing, symbolicDestinationName and tpName values must match the values of these fields defined in J2C connection factory custom properties.
The outbound code:
initialContext = new javax.naming.InitialContext();
connectionFactory = (ConnectionFactory) initialContext.lookup("snalu62");
Lu62ConnectionSpec lu62ConnectionSpec = new Lu62ConnectionSpec();
lu62ConnectionSpec.setUserName("sna");
lu62ConnectionSpec.setPassword("sna");
Connection cxn = connectionFactory.getConnection(lu62ConnectionSpec);
Interaction ixn = cxn.createInteraction();
Lu62InteractionSpec ixnSpec = new Lu62InteractionSpec();
Lu62Record outgoingData = new Lu62Record();
Lu62Record returnData = new Lu62Record();
ixnSpec.setInteractionVerb(ixnSpec.ASYNC_SEND_RECEIVE);
outgoingData.setData(requestData);
ixn.execute(ixnSpec, outgoingData, null);
ixn.close();
cxn.close();
The MDB handles the reply message for the outbound. The following is the MDB bean class:
public class MDBtest2Bean implements
javax.ejb.MessageDrivenBean,
com.ibm.connector2.sna.lu62.Lu62MessageListener {
…….
public int onOutgoingReplyMessage (String msg) {
……..
// handling the reply message for outgoing message send by CCI
}
……
}
See also
JCA LU62 sample code
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.
See also
JCA LU62 sample code
Installing the SNA JCA LU62 Connector on WebSphere Application Server
The following procedure describes how to install the SNA JCA LU62 Connector in the managed environment of WebSphere Application Server.
Before you begin, make sure that the system containing WebSphere Application Server also has IBM Communications Server Version installed.
To install the SNA JCA LU62 Connector, complete the following steps:
1 Start the WebSphere Application Server and then start the Administration Console.
2 In the left (node) pane, expand the Resources node and click Resource Adapters.
In the Resource Adapters panel, click Install RAR.
3 In the Install RAR File panel, if the RAR file is on the workstation, select Local Path and browse to the location of the RAR file. Click Next.
4 In the following panel, type an arbitrary name such as JCALU62 and description in the Name and Description fields. Click OK.
5 Return to the Resource Adapters panel (Resources > Resource Adapters) and click the name of the new resource adapter you created.
6 In the panel that appears, click J2C Activation Specifications to add new ActivationSpec JNDI name used for MDB.
7 7.Return to the Resource Adapters panel (Resources > Resource Adapters), click J2C Connection Factories. In the J2C Connection Factories panel, click New.
8 In the dialog box that pops up, type the name of the connector's connection factory (such as JCALU62_CF).
9 In the Additional Properties section, click Custom Properties.
10 In the Custom Properties panel, set the properties for the connections with values that are appropriate for your environment:
Properties for outgoing messages:
Outgoing (set to true)
SymbolicDestinationName (mandatory)
Properties for incoming messages:
Outgoing (set to false)
TpName (mandatory)
11 Copy appropriate lu62jwrap library file from the <toolkit install>/lib/comms directory to a location defined in the PATH environment variable. And rename it with appropriate file extension name according to your operating system. See Dynamic Link Libraries of JCA LU62 Connector for more information.
See also
Tasks