JMS: Server closed connection and reconnection not

2019-08-18 16:32发布

I want to count the messages in the queue.

InitialContext ctx = initQueue();
connFactory = (QueueConnectionFactory) ctx.lookup(CF_NAME);
queueConnection = connFactory.createQueueConnection();
queueConnection.start();
queueSession =
                queueConnection.createQueueSession(false, 
QueueSession.AUTO_ACKNOWLEDGE);
        queue = (Queue) ctx.lookup(queueName);

QueueBrowser queueBrowser = queueSession.createBrowser(queue);

But here it stops ------->QueueBrowser queueBrowser = queueSession.createBrowser(queue)

The error message is: Active session count: 1: org.wso2.andes.AMQDisconnectedException: Server closed connection and reconnection not permitted. javax.jms.JMSException: Error registering consumer: org.wso2.andes.AMQException: Woken up due to class javax.jms.JMSException at org.wso2.andes.client.AMQSession$6.execute(AMQSession.java:2143) at org.wso2.andes.client.AMQSession$6.execute(AMQSession.java:2086) at org.wso2.andes.client.AMQConnectionDelegate_8_0.executeRetrySupport(AMQConnectionDelegate_8_0.java:323) at org.wso2.andes.client.AMQConnection$3.run(AMQConnection.java:655) at java.security.AccessController.doPrivileged(Native Method) at org.wso2.andes.client.AMQConnection.executeRetrySupport(AMQConnection.java:652) at org.wso2.andes.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:102) at org.wso2.andes.client.AMQSession.createConsumerImpl(AMQSession.java:2084) at org.wso2.andes.client.AMQSession.createBrowserConsumer(AMQSession.java:1039) at org.wso2.andes.client.AMQQueueBrowser.(AMQQueueBrowser.java:51) at org.wso2.andes.client.AMQSession.createBrowser(AMQSession.java:1031) at org.wso2.andes.client.AMQSession.createBrowser(AMQSession.java:1018) at org.wso2.andes.client.AMQQueueSessionAdaptor.createBrowser(AMQQueueSessionAdaptor.java:87) at com.test.vediamo.ConnectionTest.doGet(ConnectionTest.java:96) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)

1条回答
仙女界的扛把子
2楼-- · 2019-08-18 17:19

Could you please create a queue first and then create the browser as follows?

QueueBrowser browser = queueSession.createBrowser(queueSession.createQueue("test-queue"));

查看更多
登录 后发表回答