Runtime components : Service components : JCA SNA Connector : JCA SNA LU0 Connector : Tasks
  
Tasks
See also
JCA LU0 Sample Code
Installing the SNA JCA LU0 Connector on WebSphere Application Server
JCA SNA LU0 Connector
JCA LU0 Sample Code
The application can call the CCI interface to send or to receive message synchronously. By using the MDB that implements the Lu0MessageListener 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 LU0 Lu0InteractionSpec Verbs
Using CCI for Outbound Communication
Inbound communication for solicited message
Inbound interface for unsolicited message
Code Page Convert
Get Session Status
Get SNA Message Indicators
SNA LU0 session affinity
Tasks
Using LU0 Lu0InteractionSpec Verbs
You can call Lu0InteractionSpec.setInteractionVerb to set the verb of the interaction.
 
Verb
Description
SYNC_SEND
Calls the Lu0SnaSession.send(inputMessage) method
SYNC_SEND_RECEIVE
Calls the Lu0SnaSession.sendReceive(inputMessage, timeout).getDataReceived() method
ASYNC_SEND_RECEIVE
Send data and then receive data asynchronously in MDBCalls the Lu0SnaSession.send(inputMessage) method
SYNC_RECEIVE
Calls the Lu0SnaSession.receiveData(timeout) method
SYNC_GET_SESSION_STATUS
Call the Lu0Session.getSessionStatus()method
SYNC_GET_ACTUAL_LU_NAME
Call the Lu0Session.getLuName ()method
Note The SYNC_GET_SESSION_STATUS and SYNC_GET_ACTUAL_LU_NAME are not supported for Dummy JCA SNA LU0 Connector.
See also
JCA LU0 Sample Code
Using CCI for Outbound Communication
// get the connectionFactory by JNDI lookup:
initialContext = new javax.naming.InitialContext();
connectionFactory = (ConnectionFactory) initialContext.lookup("snalu0");
//If you are using JCA security, pass the user name and password.
Lu0ConnectionSpec lu0ConnectionSpec = new Lu0ConnectionSpec();
lu0ConnectionSpec.setUserName("sna");
lu0ConnectionSpec.setPassword("sna");
Connection cxn = connectionFactory.getConnection(lu0ConnectionSpec);
//If you are not using JCA security, you can just get the connection: // // // Connection cxn = connectionFactory.getConnection();
//Set up the conversation:
Interaction ixn = cxn.createInteraction();
Lu0InteractionSpec ixnSpec = new Lu0InteractionSpec();
Lu0Record outgoingData = new Lu0Record();
Lu0Record returnData = new Lu0Record();
//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);
ixn.close();
cxn.close();
See also
JCA LU0 Sample Code
Inbound communication for solicited message
CCI verb ASYNC_SEND_RECEIVE send the outbound message, and the replied inbound message is received by MDB.
The outbound code:
initialContext = new javax.naming.InitialContext();
connectionFactory = (ConnectionFactory) initialContext.lookup("snalu0");
Lu0ConnectionSpec lu0ConnectionSpec = new Lu0ConnectionSpec();
lu0ConnectionSpec.setUserName("sna");
lu0ConnectionSpec.setPassword("sna");
Connection cxn = connectionFactory.getConnection(lu0ConnectionSpec);
Interaction ixn = cxn.createInteraction();
Lu0InteractionSpec ixnSpec = new Lu0InteractionSpec();
Lu0Record outgoingData = new Lu0Record();
Lu0Record returnData = new Lu0Record();
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 outbound. 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.lu0.Lu0MessageListener
</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>LuName</activation-config-property-name>
<activation-config-property-value>LUEE003</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>HostApplicationName</activation-config-property-name>
<activation-config-property-value>CICS</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.lu0.Lu0MessageListener {
…….
public int onSolicitedMessage(String msg) {
// add the application implementation of handling the inbound message here


}
……
}
See also
JCA LU0 Sample Code
Inbound interface for unsolicited message
By using MDB, the application can get the notification of the arrival of the inbound message. The MDB implements the Lu0MessageListener interface and specifies the messaging-type and activation-config-property attribute in deployment descriptor of MDB:
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.lu0.Lu0MessageListener
</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>LuName</activation-config-property-name>
<activation-config-property-value>LUEE003</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>HostApplicationName</activation-config-property-name>
<activation-config-property-value>CICS</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.lu0.Lu0MessageListener {
…….
public int onUnsolicitedMessage(String msg) {
// add the application implementation of handling the inbound message here


}
……
}
See also
JCA LU0 Sample Code
Code Page Convert
The Code Page Convert of sent and received data is optional for UDTT JCA LU0 Connector. There are three new custom properties in J2C configuration page to handle the code page convert:property.
Code Page Convert
 
property
Default value
Description
codePageConvert
false
True if code page is converted
codePage
8859_1
The code page of Application Server
codeSet
Cp037
The code set of Host
By default, the code page is not converted by JCA LU0 Connector unless the codePageConvert property is set to true.
See also
JCA LU0 Sample Code
Get Session Status
A new JCA verb SYNC_GET_SESSION_STATUS is added to get LU0 session's status. The following is the code example of using the SYNC_GET_SESSION_STATUS verb:
Lu0InteractionSpec ixnSpec = new Lu0InteractionSpec();
Lu0Record outgoingData = new Lu0Record();
Lu0Record returnData = new Lu0Record();

ixnSpec.setInteractionVerb(Lu0InteractionSpec.SYNC_GET_SESSION_STATUS);
ixn.execute(ixnSpec, null, returnData);
String status= returnData.getData();
See also
JCA LU0 Sample Code
Get SNA Message Indicators
The application can get the SNA Message Indicators like BBI, ECI, CDI from the LU0Message. The following is the sample code:
Lu0InteractionSpec ixnSpec = new Lu0InteractionSpec();
Lu0Record outgoingData = new Lu0Record();
Lu0Record returnData = new Lu0Record();
ixnSpec.setInteractionVerb(Lu0InteractionSpec.SYNC_RECEIVE);
ixnSpec.setExecutionTimeout(5000);
ixn.execute(ixnSpec, null, returnData);
String receivedData= returnData.getData();
boolean ebi=returnData.getLu0Message().getEndBracketIndicator();
See also
JCA LU0 Sample Code
SNA LU0 session affinity
The UDTT JCA LU0 Connector does not support the 1-1 session binding by UDTT product itself. It means that the application cannot specify and stick on the particular LU when there are many LUs or LU pools defined.
RUI_INIT API of SNA will return a different free LU if the specified LU is already used. And, in some cases, the specified LU name might be a LU pool. Then the JCA LU0 Connector will return an actual LU name for a LU0 connection request. Application can use the SYNC_GET_ACTUAL_LU_NAME verb to get the actual LU name.
However, the application supports 1-1 session binding based on UDTT JCA LU0 and manages it by the application code.
The property of JCA LU0 is defined in custom property of J2C connection factory in the Administrative Console of the WebSphere Application Server (WAS). It cannot bind with context. Besides, there is no automatic start up process when UDTT or WAS is started.
According to the JCA specification, the JCA connection factory that is defined in J2C WAS console with a JNDI name, gets the JCA LU0 connection. The JCA connection will be created or retrieved from WAS connection pool only upon the connection request from the application.
The automaticSessionEstablishment property of JCA LU0 only means that when the existing session is down, the session will be reestablished automatically.
Below is the session 1-1 binding sample for the case when there are multiple users and multiple LUs, and you need to bind a client with a LU. It means that after a session or connection is got from the connection factory for a client, the following communication request for this client is bind with the obtained LU.
Definition:
In the communication server, define a LU pool named LU0POOL with the LUs: LU01, LU02, LU03..LUn.
In the J2C connection factory in WAS, create a LU0 connection factory with JNDI name: LU0SNA.
For connection factory custom property definition, you can define it in the following two ways:
luNames : LU01, LU02, LU03, LU04... LUn
poolNameUsed: false
luNames : LU0POOL
poolNameUsed: true
Implementation:
Hashtable userConnectionTab=new Hashtable();
Hashtable userLuNameTab=new Hashtable();
.......
public Connection getConnectionForUser(String userID){
if (userConnectionTab.get(userID)!=null) {
return (Connection) userConnectionTab.get(userID) ;
}
else {
javax.naming.Context initialContext = new javax.naming.InitialContext();
ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("LU0SNA");
Connection connection = connectionFactory.getConnection();
// get the LU name of the obtained connection
Interaction interaction = connection.createInteraction();
Lu0InteractionSpec interactionSpec = new Lu0InteractionSpec();
interactionSpec.setInteractionVerb(Lu0InteractionSpec.SYNC_GET_ACTUAL_LU_NAME);
Lu0Record out = new Lu0Record();
interaction.execute(interactionSpec, null, out);
String luName=out.getData();
// bind the connection and LU name with userID
userConnectionTab.put(userID,connection);
userLuNameTab.put(userID,luName) ;
return connection;

}
}
public void SendReceiveData(String userID) throws NamingException, ResourceException{
Connection connection= getConnectionForUser(userID);

Interaction interaction = connection.createInteraction();
Lu0InteractionSpec interactionSpec = new Lu0InteractionSpec();
interactionSpec.setInteractionVerb(interactionSpec.SYNC_SEND);
Lu0Record in = new Lu0Record();
Lu0Record out = new Lu0Record();
in.setData("AIR2TO ");
interaction.execute(interactionSpec, in, null);
interactionSpec.setInteractionVerb(interactionSpec.SYNC_RECEIVE);
interactionSpec.setExecutionTimeout(1000);
interaction.execute(interactionSpec, null, out);
System.out.println("Data received: " + out.getData());
//only close interaction, Should NOT close connection
interaction.close();
}
See also
JCA LU0 Sample Code
Installing the SNA JCA LU0 Connector on WebSphere Application Server
To install the SNA JCA LU0Connector in the managed environment of WebSphere Application Server
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. If the RAR file is on a server, select Server Path and enter the fully qualified path to the RAR file. Click Next.
4 In the following panel, type an arbitrary name such as JCALU0 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 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 that appears, type the connector's display name (such as JCALU0_CF).
9 In the Additional Properties section, click Custom Properties.
10 In the Custom Properties panel, set the properties for the connection with values that are appropriate for your environment:
LUName (mandatory)
HostApplicationName (mandatory)
If JCA LU0 Dummy Connector is used, then only the property resFile is mandatory. The resFile should be set to an URL like http://localhost:9080/BTTSampleWeb/response.res. See Java Sample document for more information about using JCA Dummy LU0 Connector.
11 Copy the appropriate lu0wrap library file from the <toolkit install>\lib\comms directory to a location defined in the PATH environment variable.
12 Rename the file to appropriate file extension name according to your operation system being used. See Dynamic Link Libraries of Connector for more information.
See also
Tasks