現在、私はHornetQを学ぶのに苦労しています。理論的には非常に単純なようですが、最も基本的な例でさえも苦労しています。スタンドアロンサーバーとしてHornetQを実行する例
これまでは、HornetQをスタンドアロンサーバーとして起動し、メッセージを送信して戻す単純なクライアントに接続しようとしました。
私が続いてきた手順は以下のとおりです(従ってHornetQのドキュメント http://hornetq.sourceforge.net/docs/hornetq-2.0.0.GA/user-manual/en/html/using-jms.htmlへ)
はHornetQは、最新バージョンの(2.2.5)を-Downloadedし、それを抽出しました。 変性ます。install_directory \ CONFIG \スタンドアローン私は必要なオブジェクトを作成するための非クラスタ\ HornetQは、jms.xmlファイル\、以下の内容です:
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq ../schemas/hornetq-jms.xsd ">
<connection-factory name="ConnectionFactory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="ConnectionFactory"/>
</entries>
</connection-factory>
<queue name="OrderQueue">
<entry name="queues/OrderQueue"/>
</queue>
</configuration>
-Theファイルます。install_directory \ CONFIG \スタンド単独の\ non-clustered \ hornetq-beans.xmlには、JNDIサービスを開始するために必要なBeanが含まれています。
-Thereもます。install_directory内のファイルと呼ばれるjndi.propertiesです\ CONFIG \スタンドアローン\クラスタ化されていない\フォルダ
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
クライアントコードは以下の通りです:
public void test()
{
try
{
ic = new InitialContext();
cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
orderQueue = (Queue)ic.lookup("/queues/OrderQueue");
connection = cf.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(orderQueue);
consumer = session.createConsumer(orderQueue);
connection.start();
TextMessage message = session.createTextMessage("This is an order");
producer.send(message);
TextMessage receivedMessage = (TextMessage)consumer.receive();
System.out.println("Got order: " + receivedMessage.getText());
}
catch (Exception e)
{
e.printStackTrace();
}
}
しかし、私はそれを実行するたびに、次の例外を除いてクラッシュします:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
私はevそれを実行するためにerything、それでもまだ私が間違ってやっているものは私を逃す。この問題に関する提案は非常に高く評価されています!
私は同じことを言っています+1 –
さて、私はそれを試した...それは動作しません!私は、HornetQが正常に起動し、JNDIサービスを初期化し、すべての管理対象オブジェクトを作成しますが、クライアントはJNDIサービスとの通信を確立できないようです。 – steve
おそらく、JNDI(jndi.propertiesまたはそのファイルの不完全な設定がありません)が正しく使用されるように、クライアント側で行うべきことがもっとあります。 – steve