栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Tomcat的WebSphere MQ连接池

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Tomcat的WebSphere MQ连接池

正如Umapathy在选项3中所建议的那样,我们现在选择了使用Spring的CachingConnectionFactory的方法,即使对于非Spring应用程序,它也能很好地工作。您需要做的就是将Spring
Jars添加到类路径中,并用CachingConnectionFactory包装MQQueueConnectionFactory。

我们选择创建自己的Tomcat
QueueConnectionFactoryFactory,使我们能够完全保持原始应用程序代码不变,您只需要使用以下XML定义替换Tomcat配置文件(问题中所示)中的原始MQ连接工厂:

<Resource name="jms/XXXQCF" auth="Container"          type="org.springframework.jms.connection.CachingConnectionFactory"          factory="at.rsf4j.core.utilities.RSFCachingMQQueueConnectionFactoryFactory"          description="JMS Queue Connection Factory"          HOST="xxx.com" PORT="1429" CHAN="XXX" TRAN="1"          QMGR="XXX" />

这是RSFCachingMQQueueConnectionFactoryFactory的(简化)代码(无错误检查):

public class RSFCachingMQQueueConnectionFactoryFactory implements ObjectFactory{public Object getObjectInstance (Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)    throws NamingException { Reference ref = (Reference) obj; String beanClassName = ref.getClassName(); Class<?> beanClass = Class.forName(beanClassName); if (CachingConnectionFactory.class.isAssignableFrom(beanClass)){     MQQueueConnectionFactoryFactory cff = new MQQueueConnectionFactoryFactory();     Reference mqReference = new Reference(  MQQueueConnectionFactory.class.getName());     Enumeration<RefAddr> allAddrs = ref.getAll();     while (allAddrs.hasMoreElements()){         mqReference.add(allAddrs.nextElement());     }     MQQueueConnectionFactory cf = (MQQueueConnectionFactory)cff.getObjectInstance(mqReference, name, nameCtx, environment);     CachingConnectionFactory ccf = (CachingConnectionFactory)beanClass.newInstance();     ccf.setTargetConnectionFactory(cf);     return ccf; }        }


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/394377.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号