How to connect to a HornetQ server?
cremersstijn May 27, 2014 9:25 AMI am trying to connect to a hornetq server from a groovy script:
@Grapes([ @Grab(group='org.hornetq', module='hornetq-commons', version='2.4.1.Final'), @Grab(group='jboss', module='jnp-client', version='4.2.2.GA'), @Grab(group='javax.jms', module='jms', version='1.1') ]) import javax.naming.* import javax.jms.* String remoteUrl = "jnp://10.21.120.31:4747"; Properties props = new Properties(); props.put(Context.PROVIDER_URL, remoteUrl); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); InitialContext ctx = new InitialContext(props); def connectionFactory = (QueueConnectionFactory) ctx.lookup("/ConnectionFactory")
But i get the following error:
Caught: javax.naming.CommunicationException: Could not obtain connection to any of these urls: 10.21.120.31:4747 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 retrieve stub from server 10.21.120.31:4747 [Root exception is java.io.StreamCorruptedException: invalid stream header: 00000013]]
javax.naming.CommunicationException: Could not obtain connection to any of these urls: 10.21.120.31:4747 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 retrieve stub from server 10.21.120.31:4747 [Root exception is java.io.StreamCorruptedException: invalid stream header: 00000013]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at SimpleJms.run(SimpleJms.groovy:19)
Caused by: javax.naming.CommunicationException: Failed to retrieve stub from server 10.21.120.31:4747 [Root exception is java.io.StreamCorruptedException: invalid stream header: 00000013]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:268)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
... 3 more
Caused by: java.io.StreamCorruptedException: invalid stream header: 00000013
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:255)
... 4 more
[Finished in 7.1s with exit code 1]
Any idea what i am doing wrong?