我正在尝试连接到在 jboss EAP 6.2 上运行的 HornetQ 连接工厂。
这是我的常规脚本:
@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]
这是我在独立 xml 中的 hornetq 服务器配置:
<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>