Using the CCI to access the SNA JCA LU62 Connector

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:

  1. Create the connection:
    if (initialContext == null) {
      initialContext = new javax.naming.InitialContext();
      connectionFactory = (ConnectionFactory)initialContext.lookup("snalu62"); 
    }
  2. 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();
  3. Set up the conversation:
    Interaction ixn = cxn.createInteraction();
    Lu62InteractionSpec ixnSpec = new Lu62InteractionSpec();
    Lu62Record outgoingData = new Lu62Record();
    Lu62Record returnData = new Lu62Record();
  4. 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);
  5. Set up to receive the response message:
    ixnSpec.setInteractionVerb(ixnSpec.SYNC_RECEIVE);
    ixnSpec.setExecutionTimeout(500);
    ixn.execute(ixnSpec, null, returnData);
  6. 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()); 
  7. Close the conversation and connection:
    ixn.close();
    cxn.close();