Free-从心开始
宁可选择放弃,不可放弃选择
登录
注册
全站
当前博客
空间
博客
好友
相册
留言
用户操作
[即时聊天]
[发私信]
[加为好友]
刘飞
ID:supersue
共
11178
次访问,排名
10043(1)
好友
2
人,关注者
4
人
宁可选择放弃,不要放弃选择
supersue的文章
原创 28 篇
翻译 0 篇
转载 2 篇
评论 24 篇
Free-从心开始的公告
该博客中所有的文章版权归原文作者所有,任何人需要转载文章,必须征得原文作者授权。
最近评论
文章分类
Hibernate
(RSS)
JBoss
(RSS)
JMS
(RSS)
Network
(RSS)
Other
(RSS)
Spring
(RSS)
七七八八
(RSS)
项目管理
(RSS)
收藏
相册
存档
2008年04月(11)
2008年01月(2)
2007年12月(7)
2007年11月(10)
软件项目交易
订阅我的博客
JMS(Jboss Messaging)的一点使用心得(十二)多线程的ClassLoader
收藏
新一篇: JMS(Jboss Messaging)的一点使用心得(十三)拔网线后的重连----JMS Connection原理浅析及应用
|
旧一篇: JMS(Jboss Messaging)的一点使用心得(十一)Spring扩展应用-可自动重连的JmsMessageListenerContainer的另一种实现
在可自动重连的
JmsMessageListenerContainer中,有一个ClassLoader的属性值,请参见
[
http://blog.csdn.net/supersue/archive/2008/04/02/2244727.aspx
]
在
JmsMessageListenerContainer被初始化的时候(afterPropertiesSet),该ClassLoader被赋值,代码如下:
@Override
public
void
afterPropertiesSet() ...
...
{
super
.afterPropertiesSet();
this
.classLoader =
Thread.currentThread().getContextClassLoader();
}
而在发生异常启动线程重新连接的时候(onException),把该值赋给了重连线程,如下所示:
public
void
onException(JMSException e) ...
...
{
this
.logger.error(
this
.getBeanName()
+
"
Connection Error:
"
+
e.getMessage());
if
(
this
.checker
!=
null
) ...
...
{
this
.checker.shutdown();
this
.checker
=
null
;
}
this
.checker
=
new
CheckConnectionThread();
this
.checker.setDaemon(
true
);
this
.checker.setContextClassLoader(
this
.classLoader);
this
.checker.start();
}
这样做的原因是因为启动
JmsMessageListenerContainer的线程和执行onExcetion的线程不是同一个线程,ClassLoader也不一样,如果不把原来的ClassLoader保留的话,会导致重连前可以正常处理Jms消息,而重连后却发生NoClassFound错误。
发表于 @
2008年04月03日 09:44:00
|
评论(
loading...
)
|
编辑
新一篇: JMS(Jboss Messaging)的一点使用心得(十三)拔网线后的重连----JMS Connection原理浅析及应用
|
旧一篇: JMS(Jboss Messaging)的一点使用心得(十一)Spring扩展应用-可自动重连的JmsMessageListenerContainer的另一种实现
评论:没有评论。
发表评论
姓 名:
主 页:
校验码:
看不清,换一张
当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击
登录