standalone-full.xml
構成プロファイルとして使用して、JBoss AS 7.1.1.FINAL で実行される JMS キューを構成しました。
次に、JBoss サンプル コードに基づいて、キューに接続してメッセージを送信するスタンドアロンの Java プログラムを作成しました。
public class RemoteProducer {
private static final Logger log = Logger.getLogger(RemoteProducer.class.getName());
// Set up all the default values
private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
private static final String DEFAULT_DESTINATION = "jms/queue/test";
private static final String DEFAULT_USERNAME = "jmstest";
private static final String DEFAULT_PASSWORD = "fluppy";
private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
private static final String PROVIDER_URL = "remote://localhost:4447";
/**
* @param args
*/
public static void main(String[] args) {
ConnectionFactory connectionFactory = null;
Connection connection = null;
Session session = null;
MessageProducer producer = null;
Destination destination = null;
Context context = null;
try {
// Set up the context for the JNDI lookup
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));
env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", DEFAULT_USERNAME));
env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", DEFAULT_PASSWORD));
context = new InitialContext(env);
// Perform the JNDI lookups
String connectionFactoryString = System.getProperty("connection.factory", DEFAULT_CONNECTION_FACTORY);
log.info("Attempting to acquire connection factory \"" + connectionFactoryString + "\"");
connectionFactory = (ConnectionFactory) context.lookup(connectionFactoryString);
log.info("Found connection factory \"" + connectionFactoryString + "\" in JNDI");
String destinationString = System.getProperty("destination", DEFAULT_DESTINATION);
log.info("Attempting to acquire destination \"" + destinationString + "\"");
destination = (Destination) context.lookup(destinationString);
log.info("Found destination \"" + destinationString + "\" in JNDI");
// Create the JMS connection, session, producer, and consumer
connection = connectionFactory.createConnection(System.getProperty("username", DEFAULT_USERNAME), System.getProperty("password", DEFAULT_PASSWORD));
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(destination);
connection.start();
// TODO send messages
} catch (NamingException e) {
e.printStackTrace();
} catch (JMSException e) {
e.printStackTrace();
}
}
}
残念ながら、 への呼び出しconnectionFactory.createConnection
は JMS 例外 ( HornetQException[errorCode=3 message=Timed out waiting to receive cluster topology. Group:null
)で失敗します。
ログ:
Nov 06, 2012 3:37:42 PM de.test.jms.RemoteProducer main
INFO: Attempting to acquire connection factory "jms/RemoteConnectionFactory"
Nov 06, 2012 3:37:42 PM de.test.jms.RemoteProducer main
INFO: Found connection factory "jms/RemoteConnectionFactory" in JNDI
Nov 06, 2012 3:37:42 PM de.test.jms.RemoteProducer main
INFO: Attempting to acquire destination "jms/queue/test"
Nov 06, 2012 3:37:42 PM de.test.jms.RemoteProducer main
INFO: Found destination "jms/queue/test" in JNDI
javax.jms.JMSException: Failed to create session factory
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119)
at de.test.jms.RemoteProducer.main(RemoteProducer.java:60)
Caused by: HornetQException[errorCode=3 message=Timed out waiting to receive cluster topology. Group:null]
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:804)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)
... 2 more
質問:クラスタは関与していません。両方のプログラムが同じマシンで実行されています。IP アドレスをまったく構成していません。JBoss 構成で何が欠けているのか、誰にも分かりますか?
どんなヒントでも歓迎します:-)