非同期コールアウト要求を検索するためのサンプル Java アプリケーション

IMS™ アプリケーション・プログラムからのインバウンド要求に対応するように非 MDB Java アプリケーションを準備するには、Java アプリケーションで、適切な対話 Verb、非同期保留キュー名、およびタイムアウト値を指定します。

次のサンプル・コードは、コールアウト要求を受信するように構成された Java アプリケーションの例を示しています。

// JNDI lookup returns connFactory 
InitialContext initCntx = new InitialContext();
ConnectionFactory connFactory = 
      (ConnectionFactory) initCntx.lookup("java:comp/env/ibm/ims/IMSTarget"); 

IMSConnectionSpec connSpec = new IMSConnectionSpec();
Connection connection = connFactory.getConnection(connSpec);
Interaction interaction = connection.createInteraction(); 
IMSInteractionSpec interactionSpec = new IMSInteractionSpec(); 

//set the commit mode and sync level 
interactionSpec.setCommitMode(0); 
interactionSpec.setSyncLevel(1);

// An eight-character queue name that the asynchronous messages to be retrieved from
String calloutQueueName = new String ("CALLOUTQ");
// Set the asynchronous queue name for the callout message
interactionSpec.setAltClientID(calloutQueueName);
 
// Set interactionVerb to retrieve async output with a timeout
interactionSpec.setInteractionVerb(com.ibm.connector2.ims.ico.
IMSInteractionSpec.SYNC_RECEIVE_CALLOUT);
interactionSpec.setExecutionTimeout(3600000);

for (;;) {
      try {
            // Execute the interaction
            iteraction.execute(interactionSpec, null, calloutMsg); 

            // Further processing on the calloutMsg
            :
      } catch (Exception e) {
            // if the exception is an execution timeout error,
            // you can either do nothing and continue to loop
            // or process the error and then break the loop
            break;
      }
}

iteraction.close(); 
connection.close();

フィードバック