Jaideep, You are correct. You can do the instantiation in a synchronized method to avoid the issues with the static MQEnvironment variables.
However, I prefer to avoid synchronized methods when at all possible. Connecting to a queue manager is a relatively expensive operation. If you use the constructor that uses a hashtable as its parm, you don't have to synchronize around it. We happened to have a servlet based application developed "in house" that required the use of multiple queue managers. That application occasionally failed on a "connect". I traced it down to the fact that the app was using the MQEnvironment vars for the instantiation and occasionally two servlet threads were attempting to connect to different queue managers and were stepping on each others connection info. Rather than take the performance hit of doing all connections via a sychronized method, the use of the hash table for the same parms you would have set via the static MQEnvironment vars fixed the problem. John Zerbe - Mellon Financial Corp. Information Technology Solutions - Middleware Team Phone: 412-234-1048 E-Mail:[EMAIL PROTECTED] AIM: 153-1315 -----Original Message----- From: Pillai Jaideep, App Spec, SCS-SD [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 13, 2003 2:21 AM To: [EMAIL PROTECTED] Subject: On the MQ code snippet Hi Zerbe, I do not see your concern in the code snippet attached by Urvesh. The JVM guarantees that constructors are thread safe. Your cobcern should only apply when the instantiation happens within a method that is not synchronized and hence not thread safe. Thanks, Jaideep. =========================================================================== 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 DISCLAIMER: The information contained in this e-mail may be confidential and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorized. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator. ==========================================================================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
