首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为什么在回收到远程队列的客户端JBoss连接后仍然抛出SpyJMSExceptions?

为什么在回收到远程队列的客户端JBoss连接后仍然抛出SpyJMSExceptions?
EN

Stack Overflow用户
提问于 2015-01-10 06:37:30
回答 1查看 1.7K关注 0票数 56

下面的应用程序作为JBoss 7.2.0系统上的客户端与JBoss 4.2.1系统上的接收方JNDI/JMS进行通信。它创建一个发送队列和一个接收队列。我们已经用这个配置运行了2个月,两边都没有任何变化。本地客户端应用程序安装了4.2.1 jbossall-client.jar和jnp-client.jars。

在正常活动之后,我们开始接收org.jboss.mq.SpyJMSException: Exiting on IOE; - nested throwable: (java.io.EOFException) at org.jboss.mq.SpyJMSException.getAsJMSException(SpyJMSException.java:72)异常。

我们在未做任何更改的情况下重新启动了JBoss 7.2.0,并且在建立接收队列时,我们现在在QueueReceiver receiver = session.createReceiver(queue);处收到代码抛出的org.jboss.mq.SpyJMSException: Cannot subscribe to this Destination: ; {...} Caused by: java.io.EOFException异常。我们也开始抛出同样的异常,当应用程序已经运行了几天,但在多天的时间内没有活动。

我们让4.2.1系统重新启动,看看这是否是问题所在,但这并没有解决任何问题。事实上,我们可以通过让两个系统正常连接,然后重新启动4.2.1系统来复制这种故障情况。错误在4.2.1系统关闭后开始抛出,而7.2.0系统在4.2.1系统完全建立后仍然无法重新建立连接(即使它应该能够这样做)。

在JBoss中停止然后启动应用程序并不能解决这个问题。重启JBoss有20%的机会解决这个问题(在上面提到的强制故障情况下,有100%的可能性)。取消部署,然后重新部署应用程序通常会修复此问题。

这可能是什么原因造成的?

同样的war文件在我们的测试系统上工作得很好,它具有相同的JBoss设置。在命令提示符下,通过测试应用程序使用相同的代码与目标JBoss系统进行通信。

我怀疑JBoss 7.2.0本身有问题,或者这可能是一个超时问题?我如何检查或延长超时长度;这在客户端是可行的吗?即使是超时,我在其余的start()重新连接之前调用stop()方法,仍然会得到异常;在这种情况下,这不会是超时问题,因为超时会被重置。

上下文值:

代码语言:javascript
复制
connectionFactoryName=ConnectionFactory
contextFactoryName=org.jnp.interfaces.NamingContextFactory
packagePrefixes=org.jboss.naming:org.jnp.interfaces
providerUrl=MYSERVER:1099

Java代码:

代码语言:javascript
复制
private ContextContainer contextContainer = null;
private QueueConnection connection = null;
private QueueReceiver receiver = null;
private Queue sendQueue = null;
private Queue receiveQueue = null;
private String sendQueueName = null;
private String receiveQueueName = null;
private MessageHandler messageHandler = null;

protected synchronized void start() throws Exception {

    // NOTE: This position also has delay code (for pending multiple 
    // consecutive recycling requests), with an external method to 
    // reset the delay. It was removed for code clarity and has no 
    // effect on the issue being discussed.

    // Clear prior Connection
    stop();

    logger.info("Regenerating JMS for : " + this.getClass().getName());

    Context context = this.contextContainer.getContext();

    logger.info("Looking up factory : " + contextContainer.getConnectionFactoryName());

    QueueConnectionFactory connectionFactory = (QueueConnectionFactory)context.lookup(contextContainer.getConnectionFactoryName()); 

    // ESTABLISH SEND MESSAGE QUEUE
    logger.info("Looking up send queue : " + sendQueueName);

    sendQueue = (Queue)context.lookup(sendQueueName); 

    logger.info("Send Queue string : " + sendQueue);
    logger.info("Send Queue name   : " + sendQueue.getQueueName());
    logger.info("Creating Queue Connection");

    connection = connectionFactory.createQueueConnection();

    logger.info("Setting Exception Listener");

    connection.setExceptionListener(new ExceptionListener() {

        public void onException(JMSException ex) {

            logger.error("JMS Exception received on QueueConnection", ex);

            start();
        }
    });

    // ESTABLISH RECEIVE MESSAGE QUEUE
    logger.info("Looking up receive queue : " + receiveQueueName);

    receiveQueue = (Queue)context.lookup(receiveQueueName); 

    logger.info("Receive Queue string : " + receiveQueue);
    logger.info("Receive Queue name   : " + receiveQueue.getQueueName());
    logger.info("Creating JMS Session for Receiving");

    QueueSession session = connection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);

    logger.info("Created Session " + session);      
    logger.info("Creating JMS Receiver for Queue \"" + receiveQueue.getQueueName() + "\"");

    // THIS IS THE LINE WHERE THE EXCEPTION IS THROWN!!!
    receiver = session.createReceiver(receiveQueue);

    logger.info("Setting Message Listener");

    receiver.setMessageListener(new MessageListener() {

        public void onMessage(Message message) {

            try {

                if (message instanceof ObjectMessage) {

                    Object obj = ((ObjectMessage) message).getObject();

                    //  UNRELATED METHOD FOR HANDLING THE MESSAGE
                    handleMessage(obj);

                } else {

                    throw new Exception("Received message of unexpected type " + message.getJMSType() + ", was expecting ObjectMessage");
                }

            } catch (Exception ex) {

                logger.error("Error processing incoming message.", ex);

            } finally {

                try {

                    message.acknowledge();
                    logger.info("Acknowledged message.");

                } catch (Exception ex) {

                    logger.error("Unable to acknowledge message.", ex);
                }
            }
        }
    });

    logger.info("Starting Queue Connection");

    connection.start();

    logger.info("Started Queue Connection");
}   

/**
 * Extinguish the existing connection.
 */
public synchronized void stop() {

    if (receiver != null) {

        try {

            logger.info("Nullifying Receiver Listener");
            receiver.setMessageListener(null);
            logger.info("Nullified Receiver Listener");

        } catch(Exception ex) {

            logger.warn("Exception nullifying Receiver Listener", ex);
        }

        try {

            logger.info("Closing Receiver");
            receiver.close();
            logger.info("Closed Receiver");

        } catch(Exception ex) {

            logger.warn("Exception closing Receiver", ex);

        } finally {

            receiver = null;
        }           
    }

    if (connection != null) {

        try {

            logger.info("Nullifying Exception Listener");
            connection.setExceptionListener(null);
            logger.info("Nullified Exception Listener");

        } catch (Exception ex) {

            logger.warn("Exception nullifying Exception Listener", ex);
        }

        try {

            logger.info("Stopping Queue Connection");
            connection.stop();
            logger.info("Stopped Queue Connection");

        } catch (Exception ex) {

            logger.warn("Exception stopping Queue Connection", ex);
        }

        try {

            logger.info("Closing Queue Connection");
            connection.close();
            logger.info("Closed Queue Connection");

        } catch (Exception ex) {

            logger.warn("Exception closing Queue Connection", ex);

        } finally {

            connection = null;
        }
    }
}

日志输出:

代码语言:javascript
复制
Setting Context Factory Class: org.jnp.interfaces.NamingContextFactory
Setting Package Prefixes: org.jboss.naming:org.jnp.interfaces
Setting Provider URL: MYSERVER:1099
Generating JMS for : MYPACKAGE.ConnectionHandler
Looking up factory : ConnectionFactory
Looking up send queue : queue/sendQueue
Send Queue string : QUEUE.sendQueue
Send Queue name   : sendQueue
Creating Queue Connection
Setting Exception Listener
Looking up receive queue : queue/receiveQueue
Receive Queue string : QUEUE.receiveQueue
Receive Queue name   : receiveQueue
Creating JMS Session for Receiving
Created Session SpySession@1903462020[tx=false ack=CLIENT txid=null RUNNING connection=Connection@1963631553[token=ConnectionToken:ID:273725/9966a9625bb094d33a37f72db71b3bb9 rcvstate=STOPPED]]
Creating JMS Receiver for Queue "receiveQueue"
Exception caught during initialization.
org.jboss.mq.SpyJMSException: Cannot subscribe to this Destination: ; - nested throwable: (java.io.EOFException)

正常活动后的异常跟踪:

代码语言:javascript
复制
JMS Exception received on QueueConnection
org.jboss.mq.SpyJMSException: Exiting on IOE; - nested throwable: (java.io.EOFException)
at org.jboss.mq.SpyJMSException.getAsJMSException(SpyJMSException.java:72)
at org.jboss.mq.Connection.asynchFailure(Connection.java:423)
at org.jboss.mq.il.uil2.UILClientILService.asynchFailure(UILClientILService.java:174)
at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleStop(SocketManager.java:439)
at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:371)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2766)
at java.io.ObjectInputStream.readByte(ObjectInputStream.java:916)
at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:316)
... 1 more

重启后的异常跟踪:

代码语言:javascript
复制
org.jboss.mq.SpyJMSException: Cannot subscribe to this Destination: ; - nested throwable: (java.io.EOFException)
    at org.jboss.mq.SpyJMSException.getAsJMSException(SpyJMSException.java:72)
    at org.jboss.mq.SpyJMSException.rethrowAsJMSException(SpyJMSException.java:57)
    at org.jboss.mq.Connection.addConsumer(Connection.java:800)
    at org.jboss.mq.SpySession.addConsumer(SpySession.java:947)
    at org.jboss.mq.SpySession.createReceiver(SpySession.java:658)
    at org.jboss.mq.SpyQueueSession.createReceiver(SpyQueueSession.java)
    at org.jboss.mq.SpySession.createReceiver(SpySession.java:647)
    at org.jboss.mq.SpyQueueSession.createReceiver(SpyQueueSession.java)
    at MYPACKAGE.ConnectionHandler.start(ConnectionHandler.java:144)
    at MYPACKAGE.ConnectionHandler.initialize(ConnectionHandler.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777)
    at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156)
    at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60)
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.io.EOFException
    at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2766)
    at java.io.ObjectInputStream.readByte(ObjectInputStream.java:916)
    at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:316)
    at java.lang.Thread.run(Thread.java:744)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-16 00:10:49

如问题中所述,JBoss 4.2.1服务器已升级到7.1.1最终版本。升级已经解决了这个问题,客户端现在可以正常工作,但不幸的是,这个解决方案不能解释这个问题。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27870398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档