jms的使用中,实现MessageListener的类为何不能自动调用onMessage()方法??

lgf6 2004-01-14 06:13:29
各位大佬:

msgListenter是一个实现了MessageListener接口的类。

我在使用
QueueReceiver.setMessageListener(msgListener);方法时,系统不能自动去调用msgListener类里的onMessage()方法。

注:在weblogic上就可以调用,但是在was上就不行。请高手告诉我原因是什么呀?

而且系统没有抛出任何异常!!
...全文
597 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dropship 2004-06-29
  • 打赏
  • 举报
回复
lgf6(lili6)的MSN就没有开过
lgf6 2004-01-16
  • 打赏
  • 举报
回复
这个问题我已经用另外一中办法解决了,谢谢你冰雪!
lgf6 2004-01-15
  • 打赏
  • 举报
回复
我写了一个客户端程序调用这个方法,上下文环境变量初始化成功后,我在lookup jmsFactory jndiname的时候怎么总是有异常?

我配置的jndi名称是:hello/ConnectionFactory

QueueConnectionFactory qcf = (QueueConnectionFactory)iniCtx.lookup("hello/ConnectionFactory");

总是抛出如下异常:
javax.naming.NamingException: Failed to initialize the ORB [Root exception is java.lang.reflect.InvocationTargetException]
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:324)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:363)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:102)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:408)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:131)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at test.message.MessageReceiver.init(MessageReceiver.java:61)
at test.message.MessageReceiver.<init>(MessageReceiver.java:37)
at test.message.MessageReceiver.main(MessageReceiver.java:131)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:313)


请大虾告诉我是怎么回事好吗?
iceleighton 2004-01-15
  • 打赏
  • 举报
回复
你的问题在于你可能是你在容器内使用了新的线程,给你个连接自己看吧:
http://groups.google.com/groups?hl=zh-CN&lr=&ie=UTF-8&oe=UTF-8&frame=right&th=e89bf90c02c72eab&seekm=b87avp%2437ju%241%40news.boulder.ibm.com#s
lgf6 2004-01-15
  • 打赏
  • 举报
回复
我又调试了一下,发现是
QueueReceiver.setMessageListener(msgListener); 的错误。
异常如下:

setMsgListener 异常!e= javax.jms.IllegalStateException: Method setMessageListener not permitted


为什么setMessageListener 方法被禁止呢?在jms规范上这个是可以用的呀,而且我在weblogic上测试都是可以通过的。请各位帮我看看好吗?
iceleighton 2004-01-15
  • 打赏
  • 举报
回复
你的客户端程序是使用WSAD开发的客户机应用吗?
如果不是,可能不行,客户机必须运行在WAS的Client Container里面。
给你个连接自己看看:
http://www-106.ibm.com/developerworks/websphere/techjournal/0211_barcia/barcia.html

2,633

社区成员

发帖
与我相关
我的任务
社区描述
WebSphere 是 IBM 的软件平台。它包含了编写、运行和监视全天候的工业强度的随需应变 Web 应用程序和跨平台、跨产品解决方案所需要的整个中间件基础设施,如服务器、服务和工具。
社区管理员
  • WebSphere社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧