ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Reasons 2018 and 2019 when using connection pooling

Post new topic  Reply to topic
 Reasons 2018 and 2019 when using connection pooling « View previous topic :: View next topic » 
Author Message
jtaylor6806
PostPosted: Wed Jun 13, 2012 10:55 am    Post subject: Reasons 2018 and 2019 when using connection pooling Reply with quote

Newbie

Joined: 13 Jun 2012
Posts: 6

I'm using MQ version 7.1, and the errors are not returned to my application as MQExceptions. They are simply logged to stderr, and messages are processed correctly. However, I'm concerned that connection pooling isn't really happening; i.e. the pool is detecting a problem, issuing the error, deleting the "bad" connection and then establishing a new physical connection. I can use MQException.logExclude() to stop logging the errors to stderr, but that may just be masking an actual problem. Can someone explain what's going on?

Here is the test program I'm using that shows the behavior:

Code:
import com.ibm.mq.MQEnvironment;
import com.ibm.mq.MQException;
import com.ibm.mq.MQGetMessageOptions;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;
import com.ibm.mq.constants.CMQC;
import com.ibm.mq.constants.MQConstants;


public class MQTest {

   /**
    * Main
    */
   public static void main(String[] args)
   {
      MQTest theTest = new MQTest();
      theTest.run();
   }

   /**
    * Set up to connect to MQ and retrieve messages
    */
   public void run()
   {
      try {
         // Set up for client connection
         MQEnvironment.channel = "DESKTOP_SERVER_CONN";
         MQEnvironment.hostname = "localhost";
         MQEnvironment.port = 1414;
         MQEnvironment.properties.put(MQConstants.TRANSPORT_PROPERTY,
                  MQConstants.TRANSPORT_MQSERIES_CLIENT);
   
         // Waiting on input messages times out and returns 2033 (MQRC_NO_MSG_AVAILABLE) errors,
         // which are normal.  Prevent these from being logged to stderr
         MQException.logExclude(MQConstants.MQRC_NO_MSG_AVAILABLE);
   
         // Activate the default MQ connection pool
         MQEnvironment.addConnectionPoolToken();
         
         // Get messages until none are left
         for (; ;) {
            if (getMessage() == null) {
               break;
            }
            System.out.println("Got a message...");
            // Slow things down a bit
            try {
               synchronized (this) {
                  wait(100);
               }
            } catch (InterruptedException e) {}
         }
      }
      catch (MQException e) {
         System.out.println(e);
      }
   }
   
   /**
    * Get a message from the queue
    */
   protected MQMessage getMessage() throws MQException
   {
      MQQueueManager   queueManager = null;
      MQQueue       queue = null;
      MQMessage      message = null;
      
      try {
         /* Queue Manager */
         queueManager = new MQQueueManager("DESKTOP_QUEUE_MANAGER");
         /* Queue */
         queue = queueManager.accessQueue("REQUEST_QUEUE",
               CMQC.MQOO_INPUT_AS_Q_DEF | CMQC.MQOO_FAIL_IF_QUIESCING | CMQC.MQOO_INQUIRE);
         /* Message options */
         MQGetMessageOptions getMessageOptions = new MQGetMessageOptions();
         getMessageOptions.waitInterval = 10000;
         getMessageOptions.options = CMQC.MQGMO_WAIT | CMQC.MQGMO_NO_SYNCPOINT
               | CMQC.MQGMO_FAIL_IF_QUIESCING | CMQC.MQGMO_COMPLETE_MSG;
         getMessageOptions.matchOptions = CMQC.MQMO_NONE;
         /* Message */
         message = new MQMessage();
         queue.get(message, getMessageOptions);
      }
      catch (MQException e) {
         if (e.getReason() == MQConstants.MQRC_NO_MSG_AVAILABLE) {
            message = null;
         }
         else {
            throw e;
         }
      }
      finally {
         // Close the queue and disconnect from the queue manager
         if (queue != null) {
            try {
               queue.close();
            } catch (Exception e2) {} // Ignore secondary error
         }
         if (queueManager != null) {
            try {
               queueManager.disconnect();
            } catch (Exception e2) {} // Ignore secondary error
         }
      }
      return message;
   }
}


Here is the output from the test program:

Code:
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
MQJE001: Completion Code '2', Reason '2019'.
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...
Got a message...


Last edited by jtaylor6806 on Wed Jun 13, 2012 2:08 pm; edited 2 times in total
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jun 13, 2012 11:23 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.csqzaw.doc%2Fja11220_.htm
Back to top
View user's profile Send private message
jtaylor6806
PostPosted: Wed Jun 13, 2012 11:28 am    Post subject: Reply with quote

Newbie

Joined: 13 Jun 2012
Posts: 6

Are you suggesting RTFM? Believe me, I have done so. I did fail to mention that my application is running within an OSGi framework, although I don't know why that would affect things.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jun 13, 2012 11:50 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

jtaylor6806 wrote:
Are you suggesting RTFM? Believe me, I have done so.


I don't see where your code is exploiting the technology indicated in the specific InfoCenter page referenced by that link.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
jtaylor6806
PostPosted: Wed Jun 13, 2012 11:59 am    Post subject: Reply with quote

Newbie

Joined: 13 Jun 2012
Posts: 6

Vitor wrote:
jtaylor6806 wrote:
Are you suggesting RTFM? Believe me, I have done so.


I don't see where your code is exploiting the technology indicated in the specific InfoCenter page referenced by that link.


That's fair enough. I did not snip that piece of the code, although I mentioned in the explanation above it "Each thread calls MQEnvironment.addConnectionPoolToken(), and I'm using the default connection pool."

The OSGi architecture makes the class structure a little convoluted. There is a master object that sets up the MQEnvironment and exposes a threadInit() method, and that's where the MQEnvironment.addConnectionPoolToken() happens. Each worker thread calls threadInit() at start up. I'm sure connection pooling is happening, because I don't get the 2018/2019 errors when I comment out the call to addConnectionPoolToken().
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jun 13, 2012 1:00 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

jtaylor6806 wrote:
Vitor wrote:
jtaylor6806 wrote:
Are you suggesting RTFM? Believe me, I have done so.


I don't see where your code is exploiting the technology indicated in the specific InfoCenter page referenced by that link.


That's fair enough. I did not snip that piece of the code, although I mentioned in the explanation above it "Each thread calls MQEnvironment.addConnectionPoolToken(), and I'm using the default connection pool."


It was indeed in your explantory text, which I did indeed fail to see. But, hard to see.

jtaylor6806 wrote:
The OSGi architecture makes the class structure a little convoluted.

I'm always willing to believe that OSGi has made a mess of everything.

jtaylor6806 wrote:
There is a master object that sets up the MQEnvironment and exposes a threadInit() method, and that's where the MQEnvironment.addConnectionPoolToken() happens. Each worker thread calls threadInit() at start up. I'm sure connection pooling is happening, because I don't get the 2018/2019 errors when I comment out the call to addConnectionPoolToken().

If you look at the sample again, you'll see that it only creates a single PoolToken, not one token for each connection. Your model appears to be setting one for each connection.

Please also remember that MQEnvironment is a static object that is visible and settable by all threads. So unless you've taken steps, or your threadInit() is already synchronized, you could be running into issues with that.
Back to top
View user's profile Send private message
jtaylor6806
PostPosted: Wed Jun 13, 2012 2:11 pm    Post subject: Reply with quote

Newbie

Joined: 13 Jun 2012
Posts: 6

To make things easier, I created a small, single-threaded test program by cutting and pasting the code from my real application. I've edited the first post to show the test program and its output. I think I'm doing things according to IBM's documentation. Note that if I comment out the call to MQEnvironment.addConnectionPoolToken(), then I no longer see the 2019 errors.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jun 13, 2012 5:00 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Take an MQ client trace and see which object/call is returning the MQRC 2019.

Or put each queue operation in it's own try/catch to isolate, and determine if it's actually the connection that's gone bad or if it's something else.
Back to top
View user's profile Send private message
jtaylor6806
PostPosted: Thu Jun 14, 2012 3:57 am    Post subject: Reply with quote

Newbie

Joined: 13 Jun 2012
Posts: 6

I'll look into getting a trace. As far as isolating the MQ calls in separate try/catch blocks, the program does not receive any exceptions. The 2019 errors are logged to stderr, and I assume they come from MQ's connection pool code. My program is not writing the MQJE001 message. My program runs normally to completion.

Perhaps the details of the MQ client run time environment are significant. I'm running on 64-bit Windows 7. When running within the OSGi framework, I'm using the com.ibm.mq.osgi.java_7.1.0.0.jar file. For the single-threaded test program now listed in the first post above, I simply unpacked the individual jar files contained in the OSGi bundle and added the jar files to the classpath. The native DLLs are in C:\Program Files (x86)\IBM\WebSphere MQ\java\lib64.

The test program shown above is so simple, as is the method for implementing IBM's connection pooling, that I have to believe the 2019 errors are normal. That is, the connection pooling expects these errors and deals with them. The usual logging of the error message to stderr still takes place, and the customer can use MQException.logExclude() to suppress the logging. What bothers me about assuming this, is I'd think IBM would mention the behavior just to prevent a lot of annoying support calls. I also think I'd have found others asking about this somewhere on the internet.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Jun 14, 2012 5:46 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

from the documentation:
Quote:
•The handle is a shared handle that has been made invalid by another thread issuing the MQCLOSE call.

I would guess that this case is what you are running into.
How do you return the handle to the pool?

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jtaylor6806
PostPosted: Thu Jun 14, 2012 5:52 am    Post subject: Reply with quote

Newbie

Joined: 13 Jun 2012
Posts: 6

fjb_saper wrote:

How do you return the handle to the pool?


The first post contains the complete listing for the program. I call "queueManager.disconnect()" to return the handle to the pool.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Reasons 2018 and 2019 when using connection pooling
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.