On 5/18/07, JohnF <[EMAIL PROTECTED]> wrote:

Hello,

I tried to use JNDI and the lookup() methode to get a topic for a client.

            properties = new Hashtable<String, String>();

            properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");

            Context context = new InitialContext(properties);

            ConnectionFactory connectionFactory =
(ConnectionFactory)context.lookup("ConnectionFactory");

            properties.put(Context.PROVIDER_URL, "tcp://localhost:61616");

           Topic destination = (Topic)context.lookup("NAME_OF_TOPIC");

It failed and I got the NameNotFoundException. If I added the following
line, it does work:

            properties.put("topic.NAME_OF_TOPIC", "NAME_OF_TOPIC");

I do not want to use a property file that is stored in the classpath. How do
I have to configure a topic or a queue to avoid defining the Name of the
destination for JNDI in the code of the client?

You could load the properties file from some remote resource (file
server, web server, database). Or you could use some other JNDI
provider if you want (Sun's or one from your J2EE container) - which
amounts to the same thing but adds tons of work usually.

Or use spring and put the creation of the destinations in your
spring.xml. Or just ditch JNDI/spring entirely and use the JMS API to
create the topics you want?

--
James
-------
http://macstrac.blogspot.com/

Reply via email to