IMS Java dependent region resource adapter support for ICAL callout with control data
IMS transactions that are written in Java and leverage the IMS Java dependent region resource adapter can issue ICAL calls that include control data.
By using control data, you can include any information in an ICAL callout message such as the endpoint information or other routing specifications.
The support for ICAL callout with control data uses the IMS implementation of the Java Message Service (JMS) API in the IMS Java dependent region resource adapter (imsutm.jar). The IMS Java dependent region resource adapter invokes the Universal Drivers C library (DFSCLIBU, in the SDFSJLIB data set) through JNI calls to issue the calls from C to the AIBTDLI interface with the ICAL information.
The following example illustrates an IMS IMS Java dependent region resource adapter JMP application that issues a synchronous callout message with control data:
public static void main(String args[]) {
// Create an IMS JMP application
app = ApplicationFactory.createApplication();
// Get the IMS JMS queue connection factory
IMSQueueConnectionFactory jmsConnectionFactory = app
.getIMSQueueConnectionFactory();
QueueConnection jmsConnection = null;
QueueSession jmsQueueSession = null;
javax.jms.Queue jmsQueue = null;
QueueRequestor jmsQueueRequestor = null;
try {
// Get a reference to the IMS message queue
msgQueue = app.getMessageQueue();
// Create an input message object
inputMessage = app.getIOMessage("class://MyInputMessage");
// Create an output message object
outputMessage = app.getIOMessage("class://MyOutputMessage");
// Retrieve messages off the queue
while (msgQueue.getUnique(inputMessage)) {
// Setting the JMS settings to issue an ICAL call
// Specify the amount of time to wait for a response from an
// ICAL call. This value
// corresponds to the RSFLD value in the AIB
jmsConnectionFactory.setTimeout(999999);
// Specify the expected size of the response message from the
// ICAL call. This value
// corresponds to the OAUSE value in the AIB
jmsConnectionFactory.setResponseAreaLength(0x00000033);
// Create the JMS queue connection
jmsConnection = jmsConnectionFactory.createQueueConnection();
// Create the JMS queue session
jmsQueueSession = jmsConnection.createQueueSession(false, 1);
// Specify the OTMA Routing descriptor which describes the
// target that the ICAL call
// will be sent to. This value correponse with the RSNM1 value
// in the AIB
jmsQueue = jmsQueueSession.createQueue("DEST0001");
// Create the JMS queue requestor
jmsQueueRequestor = new QueueRequestor(jmsQueueSession,
jmsQueue);
// Build the request area for the ICAL call
// For synchronous program switch a BytesMessage object must be
// used
BytesMessage sendMsg = jmsQueueSession.createBytesMessage();
// The content of the request area must follow the existing
// format for synchronous program switch:
// LL + ZZ + SWITCH-TO-TRAN + TRAN-INPUT
short ll = 50;
short zz = 0;
sendMsg.writeShort(ll); // Specify the LL value
sendMsg.writeShort(zz); // Specify the ZZ value
// The name of the SWITCH-TO-TRAN is 8 bytes long and encoded in
// CP1047
// This value must be converted to bytes to be written into the
// BytesMessage object
String trancode = new String("SWTCHTRN");
sendMsg.writeBytes(trancode.getBytes("Cp1047"));
// Specify the input data for the switch to transaction
sendMsg.writeUTF(inputMessage.getString("MYINPUT"));
// Build the control data object
IMSControlArea controlArea = new IMSControlArea();
byte controlData[] = "Richard".getBytes();
controlArea.addControlDataItem("name", controlData);
// Attach the control data object to the message object
((BytesMessageImpl) sendMsg).addControlArea(controlArea);
// The length of the request area can be retrieved by calling
// the BytesMessage.getBodyLength() method
// This value corresponds to the OALEN value in the AIB
System.out.println("Request Message Length (AIBOALEN): "
+ sendMsg.getBodyLength());
// Submit the ICAL call
// >>-ICAL--aib--request_area--responseArea---control_area---<<
// For synchronous program switch, the reply message will be a
// BytesMessage object
BytesMessage replyMsg = (BytesMessage) jmsQueueRequestor
.request(sendMsg);
// The response message will have the following format
// LL + ZZ + TRAN-OUTPUT
// Retrieve the LL field
replyMsg.readShort();
// Retrieve the ZZ field
replyMsg.readShort();
// Retrieve the output data from the switch to transaction and
// place it in the output message
outputMessage.setString("MYOUTPUT", replyMsg.readUTF());
// Send the output message back to IMS
msgQueue
.insert(outputMessage, MessageQueue.DEFAULT_DESTINATION);
}
// Terminate the application and free up any associated resources
app.end();
} catch (Exception e) {
// Error scenario, free up resources
app.end();
e.printStackTrace();
}
}