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

IMS™ アプリケーション・プログラムからのインバウンド要求に対応するように Java アプリケーションを準備するには、Java アプリケーションで、適切な対話 Verb、tpipe 名、およびタイムアウト値を指定する必要があります。

図形記述の開始。IMS TM リソース・アダプター バージョン 10.3 以降。図形記述の終了。以下のサンプルでは、IMS TM リソース・アダプター バージョン 10.3 以降が必要です。

// 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(IMSInteractionSpec.COMMIT_THEN_SEND); 
interactionSpec.setSyncLevel(IMSInteractionSpec.SYNC_LEVEL_CONFIRM);

// An 8-character name of the OTMA asynchronous hold queue that the 
// messages are to be retrieved from
String calloutQueueName = new String (“CALLOUTQ”);
// Set the queue name for the callout message
interactionSpec.setAltClientID(calloutQueueName);
 
// Set InteractionVerb for retrieving callout request with a timeout value
interactionSpec.setInteractionVerb(IMSInteractionSpec.SYNC_RECEIVE_CALLOUT);
// Specify to retrieve only synchronous callout request messages
interactionSpec.setCalloutRequestType(IMSInteractionSpec.CALLOUT_REQUEST_SYNC); 
interactionSpec.setExecutionTimeout(5000);


// Execute the interaction
iteraction.execute(interactionSpec, null, calloutRequestMsg); 

// Get correlation token
byte[] corrToken = interactionSpec.getSyncCalloutCorrelationToken();

// Further processing on the request (calloutRequestMsg)
:

// Send back the response (calloutRespondMsg) by using the SYNC_SEND interaction
interactionSpec.setInteractionVerb(com.ibm.connector2.ims.ico.IMSInteractionSpec.SYNC_SEND);
// SYNC_SEND does not support alternate client ID
interactionSpec.setAltClientID(null);  
interactionSpec.setSyncCalloutCorrelationToken(corrToken);

// Execute the interaction
iteraction.execute(interactionSpec, calloutRespondMsg, null); 

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

完全なコード・サンプルについては、ここを右クリックして、「名前を付けてリンク先を保存」(FireFox の場合) または「対象をファイルに保存」(Microsoft Internet Explorer の場合) を選択して、Java サンプル・ファイルをダウンロードしてください。


フィードバック