Error getting QueueConnection
hi
I am a newbie to JMS. I have an LDAP on a machine A and have added a ConnectionFactoryObject to it. I have my message sender in machine A and the receiver in machine B. When i try to receive the messages i am getting a error during Connection Creation.
My question is
1) Is it possible to do what i am trying to do. If so what is the mistake that i am doing..
I have given the Receiver code below
import javax.jms.*;
import javax.naming.*;
import java.util.*;
public class testLDAPConnection{
public static void main (String args[])
{
try
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,"ldap://<remotehost>:389/o=iplanet.com");
env.put(Context.SECURITY_PRINCIPAL,"cn=Directory Manager");
env.put(Context.SECURITY_CREDENTIALS,"dirmanager");
Context ctx = new InitialContext(env);
QueueConnectionFactory myQueueConnectionFactory = (QueueConnectionFactory)ctx.lookup("cn=MyConnectionFactory");
QueueConnection myQueueConnection = myQueueConnectionFactory.createQueueConnection();
Queue myQueue = (Queue)ctx.lookup("cn=MyDestination");
QueueSession myQueueSession = myQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
QueueSender myQueueSender = myQueueSession.createSender(myQueue);
/*Create and send a Text Message to the Queue*/
TextMessage myTextMsg = myQueueSession.createTextMessage();
myTextMsg.setText("Hello World");
System.out.println("Sending Message: " + myTextMsg.getText());
myQueueSender.send(myTextMsg);
/*Create a Queue Receiver
QueueReceiver myQueueReceiver = myQueueSession.createReceiver(myQueue);*/
/*Start the Queue Connection*/
myQueueConnection.start();
/*Receive a message from the queue
Message msg = myQueueReceiver.receive();*/
/*Receive the contents of the message sent*/
/*if(msg instanceof TextMessage){
TextMessage txtMsg = (TextMessage)msg;
System.out.println("Message Received:" + txtMsg.getText());
}*/
myQueueConnection.close();
myQueueSession.close();
}
catch(Exception e){
System.out.println("Exception occurred : " + e.toString());
e.printStackTrace();
}
}
}
Thanks
Narayan

