0
我需要通過Mule訂閱JMS主題。我們使用騾子3.5如何通過Mule訂閱JMS主題?
我已經安裝這個流程:
<jms:connector name="vos-jms-connector" specification="1.1"
validateConnections="true"
connectionFactoryJndiName="ConnectionFactory"
doc:name="JMS" password="guest" username="guest">
<jms:custom-jndi-name-resolver
class="org.mule.transport.jms.jndi.CachedJndiNameResolver">
<spring:property name="jndiInitialFactory"
value="org.jnp.interfaces.NamingContextFactory" />
<spring:property name="jndiProviderUrl" value="jnp://xx.xx.16.41:1099" />
</jms:custom-jndi-name-resolver>
</jms:connector>
<flow name="vcm-vos-vpo-topic" doc:name="vcm-vos-vpo-topic">
<jms:inbound-endpoint topic="VPOtopic"
connector-ref="vos-jms-connector" doc:name="VPOtopic" responseTimeout="4000" />
<logger message="request for topic" level="INFO" doc:name="Logger"/>
</flow>
當我運行騾子項目我希望我可以用下面的Java代碼連接到主題(運行在另一個項目在同一臺機器上):
Properties props = new Properties();
props.setProperty(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
InitialContext context = new InitialContext(props);
TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) context.lookup("ConnectionFactory");
Topic vpoTopic = (Topic) context.lookup("VPOtopic");
不過,我得到一個 「Coneection拒絕」 異常:
Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: 127.0.0.1:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server /127.0.0.1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server /127.0.0.1:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1828)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:717)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:710)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at nl.triopsys.vcm.vos.jmsmock.Main.getInitialContext(Main.java:132)
at nl.triopsys.vcm.vos.jmsmock.Main.main(Main.java:65)
Caused by: javax.naming.CommunicationException: Failed to connect to server /127.0.0.1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server /127.0.0.1:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:359)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:284)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1798)
... 5 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server /127.0.0.1:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:329)
... 7 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:97)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:82)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:325)
... 7 more
如何連接到本地主機上的入站端點?
維克多,感謝您的回答,我想我更接近一些,請看我的編輯。 – jorrebor
對於外部連接,127.0.0.1:1099中的you jnp服務已關閉。是否有可能適用於您的其他項目,因爲該代碼位於承載jndi的同一容器上? 你可以試試telnet 127.0.0.1 1099嗎? –
謝謝。打開端口後,發生同樣的異常。 Telnet連接也被拒絕,但這是因爲你不能telnet到本地主機。還有其他建議嗎? – jorrebor