java 直接连接webphere_从远程应用程序服务器连接到Websphere Liberty jmsServer

是否可以从远程应用程序服务器连接到Websphere Liberty中部署的队列?

我使用产品的免费版本(Liberty 8.5.5.7) . 我在server.xml中配置了连接工厂:

jms服务器正在侦听localhost:7276 .

我编写了一个简单的客户端应用程序,并在类路径中包含必要的客户端jar(com.ibm.ws.ejb.thinclient_8.5.0.jar,com.ibm.ws.orb_8.5.0.jar和com.ibm.ws.sib . client.thin.jms_8.5.0.jar):

Properties env = new Properties();

env.put(Context.PROVIDER_URL,"iiop://localhost:7276");

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

InitialContext ctx = new InitialContext(env);

Object qcf = ctx.lookup("qcf/ConnectionFactory");

运行该程序会产生以下异常:

javax.naming.ServiceUnavailableException: A communication failure occurred while attempting to obtain an initial context with the provider URL: "iiop://localhost:7276". Make sure that any bootstrap address information in the URL is correct and that the target name server is running. A bootstrap address with no port specification defaults to port 2809. Possible causes other than an incorrect bootstrap address or unavailable name server include the network environment and workstation network configuration. [Root exception is org.omg.CORBA.TRANSIENT: java.net.ConnectException: Connection refused: connect:host=192.168.9.208,port=7276 vmcid: 0x4942f000 minor code: 3586 completed: No]

at com.ibm.ws.naming.util.WsnInitCtxFactory.mapInitialReferenceFailure(WsnInitCtxFactory.java:2373)

如果在Liberty中禁用此功能,则原始IBM文档不会清楚地讨论 .

Solution: 在Liberty中无法使用JNDI进行远程查找 . 使用此论坛主题:link,可以以编程方式构造ConnectionFactory .

JmsFactoryFactory jff = JmsFactoryFactory.getInstance();

JmsQueueConnectionFactory qcf = jff.createQueueConnectionFactory();

qcf.setBusName("myBus");

qcf.setProviderEndpoints("localhost:7276:BootstrapBasicMessaging");

qcf.setTargetTransportChain("InboundBasicMessaging");

在类路径中只需要这个jar:com.ibm.ws.orb_8.5.0.jar,com.ibm.ws.sib.client.thin.jms_8.5.0.jar . (在WebSphere \ AppServer \ runtimes中找到,其中WebSphere是完整的WAS安装目录)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值