JMS异常监听器 [英] JMS ExceptionListener

查看:173
本文介绍了JMS异常监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用javax.jms.Connection向JBoss501发送和从JBoss501接收JMS消息.我也在使用Connection.setExceptionListener().我想知道是否需要在Connection.start()启动连接之前设置异常侦听器?可以随意重现JBoss连接异常的任何想法,以确认是否调用了异常侦听器.

I am using javax.jms.Connection to send and receive JMS messages to/from JBoss501. I am also using the Connection.setExceptionListener(). I would like to know if the exception listener needs to be set before the connection is started by Connection.start()? Any ideas to reproduce the JBoss connection exception at will to confirm if the exception listener is invoked.

推荐答案

根据规范:

如果JMS提供程序检测到Connection对象存在严重问题,它将通知Connection对象的ExceptionListener(如果已注册).为此,它调用侦听器的onException方法,并向其传递一个描述问题的JMSException参数.

If a JMS provider detects a serious problem with a Connection object, it informs the Connection object's ExceptionListener, if one has been registered. It does this by calling the listener's onException method, passing it a JMSException argument describing the problem.

异常侦听器允许以异步方式将问题通知客户端.某些连接仅消耗消息,因此他们将没有其他方法得知连接失败.

An exception listener allows a client to be notified of a problem asynchronously. Some connections only consume messages, so they would have no other way to learn that their connection has failed.

请记住,这里有关于特定于供应商的实现的地方,关于如何处理异常.一些供应商试图修复"产品.可能的情况.

Remember that there is place for vendor specific implementation here, about how exceptions are handled. Some vendors try to "fix" the situation if possible.

现在开始在设置异常侦听器之前或之后启动连接... 始终在开始连接之前设置异常侦听器.

Now about start the connection before or after setting the exception listeneer... Always set the exception listener BEFORE starting the connection.

关于复制,我想你可以

  • 启动使用者,应运行connection.start.并等待消息.
  • 立即关闭jboss.
  • 重新启动jboss.

我还知道使用Eclipse或其他开发工具将帮助您以调试模式启动,并且您可以在任何特定时间调试器向您显示状态,只需中止jboss服务器并重新启动即可.

Also I know that using Eclipse or other dev tools will help you start in debug mode, and you can at any specific time as the debugger shows you the status just abort the jboss server and restart it again.

这篇关于JMS异常监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆