Hi,
I was trying to send message from a Stand alone java program in Websphere Server to the JMQ in Glassfish server.
Following code snippet is the one we tried. But this gives Null pointer exception when looking up the connection factory in glassfish.
public void sendMessageToQueue(String Message) throws JMSException{
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
properties.put(Context.PROVIDER_URL, "iiop://<remote serverip>:3100"); //FOR EACH SERVER MUST BE HIS OWN PROVIDER. The iiop provider is for GlassFish.*
properties.put("org.omg.CORBA.ORBInitialHost","<remote serverip>");
properties.put("org.omg.CORBA.ORBInitialPort","3100");
jndiContext = new InitialContext(properties);
System.out.println("JNDI Context Obj:" +jndiContext);
// Look up connection factory and queue.
queueConnectionFactory = (QueueConnectionFactory)jndiContext.lookup("jms/tConnectionFactory");
System.out.println("QueueConnectionFactory Obj:" +queueConnectionFactory);
queue = (Queue)jndiContext.lookup("jms/tQueue");
System.out.println("!!!!!!!"+queue);
// - Create connection
queueConnection = queueConnectionFactory.createQueueConnection();
queueConnection.start();
// - Create session from connection; false means session is not transacted.
// - Create sender and text message.
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
// - Send messages, varying text slightly.
queueSender = queueSession.createSender(queue);
//send a message
TextMessage message = queueSession.createTextMessage();
message.setText("This is a Text Message");
queueSender.send(message);
}
Is there a way to add the addresslist property to the connection factory in websphere admin console?
Should we use Default Messaging provider or the Websphere MQ Messaging provider while creating the connection factory?
[Message sent by forum member 'calay' (calay)]
http://forums.java.net/jive/thread.jspa?messageID=314748