Hi, 

I have the same problem.
In my case, a standalone java application listens on a queue, After one days working, 
this problem happened. I have an onException implemented in the application and also, 
the onException() is called. Within this onException(), i try to close() the 
oldconnection first, and then try to reestablish a connection. But it seems that the 
close() of the old connection never returns. So, there is no chance to reconnect. So, 
i decide to reconnect first and then use another thread to close the old connection 
now(Not test yet, and don't know whether it solve the problem or not).

In addition, i am wondering what happend to the connection. In my case , both listner 
and the jboss server are running in the same machine.

        public synchronized void onException(JMSException jmsException) {
                log.error("onException() is called at " + new Date());
                System.out.println("onException() is called at " + new Date());
                jmsException.printStackTrace();
                oldconnection = queueConnection;
                for (int i = 0; i < 10; i++) {
                        try {
                                ConnectorMessageListener.this.init();
                        } catch (Exception e2) {
                                log.error("reconnection failed");
                                System.out.println("reconnection failed");
                                try {
                                        log.error("sleep for 2 seconds and try 
reconnect again");
                                        Thread.sleep(2000);
                                } catch (InterruptedException e1) {
                                        e1.printStackTrace();
                                }
                        }
                }

                Thread reconnThread = new Thread() {
                        public void run() {
                                for (int i = 0; i < 100; i++) {
                                        try {
                                                if (oldconnection != null) {
                                                        oldconnection.close();
                                                        oldconnection = null;
                                                }
                                                return;
                                        } catch (Exception e) {

                                                log.error("disconnect the old 
connection failed");
                                                try {
                                                        log.error("sleep for 2 seconds 
and try disconnect again");
                                                        Thread.sleep(2000);
                                                } catch (InterruptedException e1) {
                                                        e1.printStackTrace();
                                                }
                                        }
                                }
                                log.debug("disconnect the old connection success");
                                System.out.println("disconnect the old connection 
success");
                        }
                };
                reconnThread.start();
        }



regards

yang

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3830857#3830857

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3830857


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to