0
votes

I need to subscribe to a JMS topic through Mule. We're using Mule 3.5

I have setup this flow:

<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>

When I run the Mule project I would expect that I can connect to the topic with the following java code (this runs in another project, on the same machine):

    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");

However, I get a "Coneection Refused" exception:

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

How do I connect to the inbound-endpoint on my localhost?

1

1 Answers

0
votes

Are you actually using the JNDI service? Tipically, you don't need to set the full name on the topic attribute, just use the name:

Although is weird to read from a topic and write to the same topic.