退出侦听器应用程序时 ActiveMQ 中的 SocketException

发布于 2024-07-24 01:44:06 字数 1639 浏览 3 评论 0原文

我当前正在设置运行嵌入式 ActiveMQ 代理的 Tomcat 服务器。 我正在使用 Spring 来配置 JMS。 我编写了一个测试应用程序来侦听主题,当我退出测试应用程序时,ActiveMQ 代理会抛出 SocketException。 例外情况如下:

2009-06-09 13:12:48,005 DEBUG Transport:229 - Transport failed: java.net.SocketException: Connection reset
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at org.apache.activemq.transport.tcp.TcpBufferedInputStream.fill(TcpBufferedInputStream.java:50)
        at org.apache.activemq.transport.tcp.TcpBufferedInputStream.read(TcpBufferedInputStream.java:58)
        at java.io.DataInputStream.readInt(DataInputStream.java:370)
        at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:269)
        at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:210)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:202)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:185)
        at java.lang.Thread.run(Thread.java:619)

我的测试应用程序仅加载上下文 xml 文件,每 60 秒循环休眠一次。

public static void main(String[] args) {
        long numMillisecondsToSleep = 60000; 
        new ClassPathXmlApplicationContext("client-context.xml");  

        while (true) {
            try {
                logger.info("Sleeping for 60 seconds");
                Thread.sleep(numMillisecondsToSleep);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

我想知道是否有人知道我为什么会得到这个例外。 一般来说,我对 ActiveMQ 和 JMS 非常陌生,因此任何想法将不胜感激。

I am currently setting up a Tomcat Server that is running an embedded ActiveMQ broker. I'm using Spring to configure JMS. I wrote a test application to listen to topics and when I exit the test application the ActiveMQ broker throws a SocketException. Here is the exception:

2009-06-09 13:12:48,005 DEBUG Transport:229 - Transport failed: java.net.SocketException: Connection reset
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at org.apache.activemq.transport.tcp.TcpBufferedInputStream.fill(TcpBufferedInputStream.java:50)
        at org.apache.activemq.transport.tcp.TcpBufferedInputStream.read(TcpBufferedInputStream.java:58)
        at java.io.DataInputStream.readInt(DataInputStream.java:370)
        at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:269)
        at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:210)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:202)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:185)
        at java.lang.Thread.run(Thread.java:619)

My test application just loads the context xml file, loops sleeps every 60 seconds.

public static void main(String[] args) {
        long numMillisecondsToSleep = 60000; 
        new ClassPathXmlApplicationContext("client-context.xml");  

        while (true) {
            try {
                logger.info("Sleeping for 60 seconds");
                Thread.sleep(numMillisecondsToSleep);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

I was wondering if anyone might know why I'm getting this exception. I'm very new to ActiveMQ and JMS in general so any ideas would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

臻嫒无言 2024-07-31 01:44:06

我认为有一种方法可以通过方法调用很好地关闭嵌入式代理。 发布您的配置以及嵌入代码将帮助人们弄清楚发生了什么。

I think there's a way to shut down an embedded broker nicely via a method call. Posting your config along with your embedding code will help people figure out what's going on.

触ぅ动初心 2024-07-31 01:44:06

我建议查看 Spring 的 JmsTemplates; 它将 MQ 的所有复杂性包装到一个漂亮的包中,并确保像这样的小错误不会给您带来数小时的问题。

http://activemq.apache.org/spring-support.html

I would recommend looking in to Spring's JmsTemplates; it wraps all of the complexity of MQ into a nice package and ensures little errors like this dont cause you hours of problems.

http://activemq.apache.org/spring-support.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文