Connect to Websphere Liberty jmsServer from remote application server

限于喜欢 提交于 2021-01-27 16:47:05

问题


Is it possible to connect to a queue deployed in Websphere Liberty from a remote application server?

I use the free version of the product (Liberty 8.5.5.7). I configured connection factory in server.xml:

<messagingEngine>
    <queue id="Queue1" receivedAllowed="false" maxMessageDepth="1000"/>
</messagingEngine>

<jmsQueueConnectionFactory jndiName="qcf/ConnectionFactory" connectionManagerRef="ConMgr2">
    <properties.wasJms nonPersistentMapping="ExpressNonPersistent" persistentMapping="ReliablePersistent"/>
</jmsQueueConnectionFactory>
<connectionManager id="ConMgr2" maxPoolSize="10"/>

The jms server is listening on localhost:7276.

I wrote a simple client application and include the necessary client jars in the classpath (com.ibm.ws.ejb.thinclient_8.5.0.jar, com.ibm.ws.orb_8.5.0.jar and 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");

Running the program produces this exception:

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)

The original IBM documentation does not discuss clearly, if this feature is disabled or not in Liberty.

Solution: It is not possible to use remote lookup with JNDI in Liberty. Using this forum topic: link, it is possible to construct the ConnectionFactory programatically.

JmsFactoryFactory jff = JmsFactoryFactory.getInstance();
JmsQueueConnectionFactory qcf = jff.createQueueConnectionFactory();
qcf.setBusName("myBus");
qcf.setProviderEndpoints("localhost:7276:BootstrapBasicMessaging");
qcf.setTargetTransportChain("InboundBasicMessaging");

You need only this jars in the classpath: com.ibm.ws.orb_8.5.0.jar, com.ibm.ws.sib.client.thin.jms_8.5.0.jar. (Found in WebSphere\AppServer\runtimes, where WebSphere is the full WAS installation directory)

来源:https://stackoverflow.com/questions/32822240/connect-to-websphere-liberty-jmsserver-from-remote-application-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!