Hi Ulises, Attached herewith is a sample Java application that PUTs a message to an MQ queue and then reads and displays the same. Replace the parameters with your own as indicated in the sample.
You will need "mq.jar" and/or "mqjms.jar" if you intend to use JMS too. You can get these jar files from the MA88 supportPak from IBM for MQSeries. ======================================== import com.ibm.mq.*; // Include the MQ package public class MQSample { private String hostname = "<your host name or IP>"; // define the name of your host to connect to private String channel = "<your channel name>"; // define name of channel for client to use private int port = 1414; // Note. assumes MQ Server is listening on // the default TCP/IP port of 1414 private String qManager = "<your queue manager name>"; // define name of queue manager object to // connect to. private MQQueueManager qMgr; // define a queue manager object // When the class is called, this initialisation is done first. public MQSample() { // Set up MQ environment MQEnvironment.hostname = hostname; // Could have put the hostname & channel MQEnvironment.channel = channel; // string directly here! MQEnvironment.port = port; try { qMgr = new MQQueueManager(qManager); } catch (Exception ex) { System.out.println("Error in connecting the q manager...."); } } public static void main(String args[]) { try { // Create a connection to the queue manager // Set up the options on the queue we wish to open... // Note. All MQ Options are prefixed with MQC in Java. MQSample mqsamp = new MQSample(); int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ; // Now specify the queue that we wish to open, and the open options... MQQueue dss_reply_queue = mqsamp.qMgr.accessQueue("<your queue name>", openOptions, "", "", ""); // default q manager // no dynamic q name // no alternate user id // Define a simple MQ message, and initialise it in UTF format.. MQMessage hello_world = new MQMessage(); hello_world.writeUTF("Hello World!"); // specify the message options... MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults, same // as MQPMO_DEFAULT constant // put the message on the queue dss_reply_queue.put(hello_world,pmo); // get the message back again... // First define a MQ message buffer to receive the message into.. MQMessage retrievedMessage = new MQMessage(); retrievedMessage.messageId = hello_world.messageId; // Set the get message options.. MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the defaults // same as MQGMO_DEFAULT // get the message off the queue.. dss_reply_queue.get(retrievedMessage, gmo, 100); // max message size // And prove we have the message by displaying the UTF message text String msgText = retrievedMessage.readUTF(); System.out.println("The message is: " + msgText); // Close the queue dss_reply_queue.close(); // Disconnect from the queue manager mqsamp.qMgr.disconnect(); } // If an error has occured in the above, try to identify what went wrong. // Was it an MQ error? catch (MQException ex) { System.out.println("An MQ error occurred : Completion code " + ex.completionCode + " Reason code " + ex.reasonCode); } // Was it a Java buffer space error? catch (java.io.IOException ex) { System.out.println("An error occurred whilst writing to the message buffer: " + ex); } } // end of main } // end of MQSample ======================================== I hope this helps! Best regards, Urvesh. x 4119. -----Original Message----- From: uli uu [mailto:[EMAIL PROTECTED]] Sent: Friday, January 17, 2003 8:52 AM To: [EMAIL PROTECTED] Subject: Jps(or Servlet) with MQ-SERIES in windows NT. Hello to all: I need to connect a java component (jsp or servlet) with an application by Mq-Series (the application provides a mq-series interface), but I don't know what is necessary to make this connection. Does somebody have an example in order to make the connection? I'm working in Windows NT 4.0, with tomcat. Please any aid I thank for them, since it's an urgent subject. Thank you very much, Ulises. --------------------------------- Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com