Runtime tools : Service components : JCA SNA Connector : JCA SNA LU62 Connector : Tasks : JCA LU62 sample code : Using CCI Interface for Outbound Communication
  
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();
}
Go up to
JCA LU62 sample code