If the application and the SNA JCA LU62 Connector are on the same
machine, the application can use the CCI to access the connector. The following
procedure demonstrates how to do this using a consistent sample through all
of the steps.
To have your application use the CCI to access the SNA JCA
LU62 Connector:
- Create the connection:
if (initialContext == null) {
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: Connection cxn = connectionFactory.getConnection();
- Set up the conversation:
Interaction 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);
Thread.currentThread().sleep(100);
getRequestData();
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);
- Repeat 4 and 5 for the second and subsequent request and response
messages in the conversation. At some point, the application needs
to get the data in the responses.
setResult(returnData.getData());
- Close the conversation and connection:
ixn.close();
cxn.close();