3

私の元々の問題は、最小限の依存関係でHornetQを見つけて埋め込む試みです。

避けたい項目の1つは、JNDIの必要性です。jndi locatorを実行するのではなく、すべてのオブジェクトを直接検索できるはずだと思います。

私はjndiのファンではありません。それは、名前を追跡し、他のものと競合しないようにする必要がある、がらくたのグローバルなバケツのように見えるためです。優れた抽象化により、最小限の公開が可能になります。

ところで、これは単なる一般的な観察ではありません...

4

1 に答える 1

4

例、特に「はい」と書かれたEmbeddedExample.javaを参照しているときに、自分のqに対する答えを見つけました。JNDIは必要ありません。

 // Step 1. Create the Configuration, and set the properties accordingly
     Configuration configuration = new ConfigurationImpl();
     configuration.setPersistenceEnabled(false);
     configuration.setSecurityEnabled(false);
     configuration.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));

     // Step 2. Create and start the server
     HornetQServer server = HornetQServers.newHornetQServer(configuration);
     server.start();

     // Step 3. As we are not using a JNDI environment we instantiate the objects directly
     ClientSessionFactory sf = HornetQClient.createClientSessionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()));

     // Step 4. Create a core queue
     ClientSession coreSession = sf.createSession(false, false, false);
于 2010-12-30T06:17:35.540 に答える