users@glassfish.java.net

jms message distribution

From: bahadir_g <fbahadirg_at_gmail.com>
Date: Fri, 22 May 2009 07:13:09 -0700 (PDT)

Hi,
I am doing a simple test. I have total 2 Queue's on 2 different
machines(each has 1 queue). Say A and B.
Queue's configs are identical.

I want to distribute 2 messages to queues on A and B by turn. The first one
to A and the last one to B.
I wrote the test client code below. But what I get is that, both messages
goes to A. B receives no message. (?)
I think I miss something about JMS, I reviewed some JMS resources but I
can't managed to find out the problem???


Context jndiContext = null;
ConnectionFactory connectionFactory = null;
Connection connection = null;
Session session = null;
Queue queue = null;
MessageProducer messageProducer = null;
ObjectMessage message = null;

Hashtable properties = new Hashtable(5);
properties.put("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
properties.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
properties.put("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
properties.put("org.omg.CORBA.ORBInitialHost", "............69");
properties.put("org.omg.CORBA.ORBInitialPort", "3700");

try {
jndiContext = new InitialContext(properties);
connectionFactory =
(ConnectionFactory)jndiContext.lookup("jms/ConnFactory");
queue = (Queue)jndiContext.lookup("jms/Queue");
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
messageProducer = session.createProducer(queue);


message = session.createObjectMessage();
message.setObject(new String("sdas"));
messageProducer.send(message);

// connection.close();
//session.close();
//messageProducer.close();
//jndiContext.close();
} catch (Exception e) {
e.printStackTrace();
}

properties = new Hashtable(5);
properties.put("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
properties.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
properties.put("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
properties.put("org.omg.CORBA.ORBInitialHost", "............115");
properties.put("org.omg.CORBA.ORBInitialPort", "3700");

try {
jndiContext = new InitialContext(properties);
connectionFactory =
(ConnectionFactory)jndiContext.lookup("jms/ConnFactory");
queue = (Queue)jndiContext.lookup("jms/Queue");
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
messageProducer = session.createProducer(queue);

jndiContext.close();

message = session.createObjectMessage();
message.setObject(new String("eeeeeee"));
messageProducer.send(message);
} catch (Exception e) {
e.printStackTrace();
}
-- 
View this message in context: http://www.nabble.com/jms-message-distribution-tp23671242p23671242.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.