0
votes

I'm trying to debug a web app hostde on weblogic 10r3 server. The App is receiving input from foreign IBM JMS Queue (classname: com.ibm.mq.jms.MQQueue) via Java Message Driven Beans.

I wrote a small Test App to connect to that queue and sending test messages. The problem is for now test message generates exceptions and somehow it gets put back on queue and is looping again and again. This generate lots of exceptions rendering log unreadable.

First I tried remove the poison message by constructing a consumer on my Test App, but the code blocks indefinitely on consumer.receive().

Then I tried to set JMSexpiration to some number instead of default 0, but in the end the message still used 0 as expiration.

All Ideas Welcome, Many Thanks

Code outline the JMS PRODUCER:

        static String rawTradeUpload = "some long chunk of data"

        Hashtable ht = new Hashtable();

        ht.put(Context.INITIAL_CONTEXT_FACTORY,
                weblogic.jndi.WLInitialContextFactory.class.getName());

        //ht.put(Context.PROVIDER_URL, "t3://gprimeap1d.eur.nsroot.net:12016");
        ht.put(Context.PROVIDER_URL, "t3://gprimeap1d.eur.nsroot.net:12001");

        ht.put(Context.SECURITY_PRINCIPAL, "weblogic");

        ht.put(Context.SECURITY_CREDENTIALS, "welcome5");

        Connection con = null;
        Session s = null;

        try {
            if(ctx == null)

                    ctx = new InitialContext(ht);


            ConnectionFactory myConnFactory = null;

            Queue myQueue = null;

                myConnFactory = (ConnectionFactory) ctx
                        .lookup("SwiftConnectionFactory");

                con = myConnFactory.createConnection();

                s = con.createSession(false, Session.AUTO_ACKNOWLEDGE);



                myQueue = (Queue) ctx
                        .lookup("IncomingSwiftFxQueue");


                MessageProducer producer = s.createProducer(myQueue);
                Message msg = s.createTextMessage(rawTradeUpload);

                producer.send(msg); 
                    s.close();

            con.close();

        } catch (NamingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (JMSException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
2
Can you post some portions of the code that creates the message and writes the message to the queue?Kevin Bedell
hey Kevin, here is the code for producer, i write a consumer and queue browser as well. it is all created from same sessionBen.Yan
Thanks to Both Peter and Zahir, I will consult the MQ team about back-out queue setup.Ben.Yan

2 Answers

0
votes

It is very simple to configure the backout queue and the redelivery settings on the IBM WebSphere MQ queue manager. Setting BOThreshold and BO Queue Name along with a local queue. Perhaps you might be able to convince them to make this setup, after all - you both benefit from this solution to work as good as possbile, right?

Otherwise, why don't you try to catch all exceptions and, if they occur - re-queue the failed message to an error queue on WebLogic. Seems to be a decent choice.

If you need to do receive, call it with a timeout instead.

Message msg = consumer.receive(1000L);  // wait for a message for 1 sec, then continue.
0
votes

Have you tried setting a re-delivery limit and defining an error queue destination so that after x attempts, the container takes care of moving the message to the error queue? This allows you to keep the primary queue free of the poison messages and a dedicated error queue to browse/debug issues.