JMP applications access the IMS message queue to receive messages to process and to send output messages. Therefore, you must define input and output message classes by subclassing the IMSFieldMessage class. The IMS Java class libraries provide the capability to process IMSFieldMessage objects. JMP applications commit or roll back the processing of each message by calling IMSTransaction.getTransaction().commit() or IMSTransaction.getTransaction().rollback(). JMP applications are started when IMS receives a message with a transaction code for the JMP application and schedules the message. JMP applications end when there are no more messages with that transaction code to process. A transaction begins when the application gets an input message and ends when the application commits the transaction. To get an input message, the application calls the getUniqueMessage method. The application must commit or roll back any database processing. The application must issue a commit call immediately before calling subsequent getUniqueMessage methods. Figure 18-2 shows the general flow of a JMP application program. Figure 18-2. JMP Application Examplepublic static void main(String args[]) { conn = DriverManager.getConnection(...); //Establish DB connection while(MessageQueue.getUniqueMessage(...)){ //Get input message, which //starts transaction results=statement.executeQuery(...); //Perform DB processing ... MessageQueue.insertMessage(...); //Send output messages ... IMSTransaction.getTransaction().commit(); //Commit and end transaction } conn.close(); //Close DB connection return; } JMP Applications and Conversational TransactionsA conversational program runs in a JMP region and processes conversational transactions that are made up of several steps. It does not process the entire transaction at the same time. A conversational program divides processing into a connected series of terminal-to-program-to-terminal interactions. Use conversational processing when one transaction contains several parts. A nonconversational program receives a message from a terminal, processes the request, and sends a message back to the terminal. A conversational program receives a message from a terminal and replies to the terminal, but it saves the data from the transaction in a scratch pad area (SPA). Then, when the person at the terminal enters more data, the program has the data it saved from the last message in the SPA, so it can continue processing the request without the person at the terminal having to enter the data again. The application package classes enable applications to be built using the IMS Java function. Related Reading: For details about the classes you use to develop a JMP application, see the IMS Java API Specification, which is available on the IMS Java Web site. Go to http://www.ibm.com/ims and link to the IMS Java page. |