Temporarily I have used the following to solve my problem:
Its ugly and I don't want to have this as my permanent solution, since I
have no control over the ActiveMQ connection pool etc etc.
String hostName = "server2";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.activemq.jndi.ActiveMQInitialContextFactory");
env.put(Context.PROVIDER_URL, "tcp://" + hostName + ":61616");
env.put(Context.SECURITY_PRINCIPAL, "geronimo");
env.put(Context.SECURITY_CREDENTIALS, "geronimo");
String queue1= "dynamicQueues/Queue1";
String connFactory = "ConnectionFactory";
InitialContext naming = new InitialContext(env);
QueueConnection queueConnection;
QueueConnectionFactory factory = (QueueConnectionFactory)
naming.lookup(connFactory);
queueConnection = factory.createQueueConnection();
Queue queue = (Queue)naming.lookup(queue1);
System.out.println("getting a Q connection"+queueConnection);
QueueSession publishSession =
queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
// Get a Queue Sender
QueueSender sender = publishSession.createSender(queue);
System.out.println("Sender:" + sender);
This works for me, but I have no control over the connection Pool.....
Basically I don't even know what "ConnectionFactory" is all about ? All that
I know is that its an ActiveMQConnectionFactory ....thats all.
I am not even sure, how its bound to the Geronimo JNDI app tree etc.
Any other ways to achieve the same this.
David - I need to have the activeMQ brokers turned on on both the machines.
--
View this message in context: http://www.nabble.com/JNDI-Lookup-tf2074678.html#a5718096
Sent from the Apache Geronimo - Users forum at Nabble.com.
|