Jms 如何从groovy连接到Jboss EAP 6.2中的HornetQ?

Jms 如何从groovy连接到Jboss EAP 6.2中的HornetQ?,jms,hornetq,jboss-eap-6,Jms,Hornetq,Jboss Eap 6,我正在尝试连接到运行在jboss EAP 6.2上的HornetQ连接工厂 这是我的groovy脚本: @Grapes([ @Grab(group='org.hornetq', module='hornetq-core-client', version='2.3.13.Final'), @Grab(group='org.hornetq', module='hornetq-jms-client', version='2.3.13.Final'), @Grab(group='

我正在尝试连接到运行在jboss EAP 6.2上的HornetQ连接工厂

这是我的groovy脚本:

@Grapes([
    @Grab(group='org.hornetq', module='hornetq-core-client', version='2.3.13.Final'),
    @Grab(group='org.hornetq', module='hornetq-jms-client', version='2.3.13.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"
)

但我得到了以下错误:

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:22)
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 128.8s with exit code 1]
这是我的hornetq服务器在独立xml中的配置:

 <connectors>
    <netty-connector name="netty" socket-binding="messaging"/>
    <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
        <param key="batch-delay" value="50"/>
    </netty-connector>
    <in-vm-connector name="in-vm" server-id="0"/>
</connectors>
<acceptors>
    <netty-acceptor name="netty" socket-binding="messaging"/>
    <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
        <param key="batch-delay" value="50"/>
        <param key="direct-deliver" value="false"/>
    </netty-acceptor>
     <in-vm-acceptor name="in-vm" server-id="0"/>
</acceptors>


<jms-connection-factories>
    <connection-factory name="myConnectionFactory">
        <connectors>
            <connector-ref connector-name="netty"/>
        </connectors>
        <entries>
            <entry name="/ConnectionFactory"/>
        </entries>
    </connection-factory>
</jms-connection-factories>


我需要使用远程连接工厂,请参见此示例:

此链接对我帮助很大。谢谢