我正在尝试远程连接到JBOSS EAP 6.2中嵌入的HornetQ上配置的主题。我尝试了不同的方法来执行此操作,但是都给了我相同的错误:

javax.jms.JMSException: Failed to create session factory
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:676)
at org.hornetq.jms.client.HornetQConnectionFactory.createTopicConnection(HornetQConnectionFactory.java:196)
at TesteTags.main(TesteTags.java:82)
Caused by: HornetQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=HQ119013: Timed out waiting to receive cluster topology. Group:null]
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:950)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:672)
... 2 more


我遵循了有关此快速入门的信息:Jboss Eap Quickstart: helloworld-jms

按照我的代码:

try {
    final Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.remote.client.InitialContextFactory");
    env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
    env.put(Context.PROVIDER_URL, "remote://localhost:4447");
    env.put(Context.SECURITY_PRINCIPAL, "testuser");
    env.put(Context.SECURITY_CREDENTIALS, "testpassword");

    Context context = new InitialContext(env);
    TopicConnectionFactory factory = (TopicConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
    Topic topic = (Topic) context.lookup("jms/topic/myTopic");


    Connection connection = factory.createTopicConnection("testuser", "testpassword"); // The Error occurred here
    connection.start();
    Session session = connection.createSession(false, TopicSession.AUTO_ACKNOWLEDGE);
    MessageProducer producer = session.createProducer(topic);

    Message message = session.createTextMessage("My Test Message");

    producer.send(message);

    System.out.println("It Worked!");
} catch (Exception e) {
    System.out.println("It Failed!");
    e.printStackTrace();
}


我正在使用具有默认配置的standalone-full-ha配置文件。

我在代码上做错了吗?还是我必须做的与默认配置不同的配置?

最佳答案

您是否使用与您使用的JBoss EAP版本相同的HornetQ库来编译客户端代码?您必须知道,存在版本兼容性问题,该问题不允许不同HornetQ版本的互操作性。

关于java - 与嵌入在JBOSS EAP 6.2中的HornetQ主题的连接失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37845602/

10-08 21:41