Я пытаюсь удаленно подключиться к теме, настроенной на HornetQ, встроенном в JBOSS EAP 6.2. Я пробовал разные подходы к этому, но все выдавали одну и ту же ошибку:
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 с конфигурациями по умолчанию.
Я делаю что-то не так в своем коде? Или есть какая-либо конфигурация, отличная от стандартной, которую я должен сделать?