import org.objectweb.joram.client.jms.Queue;
public class AProducer {
public static void main(String[] args) throws Exception {
Session session = null;
Connection cnx = null;
MessageProducer producer = null;
TextMessage message = null;
Queue queue = null;
ConnectionFactory cf = null;
Context initialContext = new InitialContext();
cf = (ConnectionFactory) initialContext.lookup("cf");
queue = (Queue) initialContext.lookup("queue");
initialContext.close();
cnx = cf.createConnection();
session = cnx.createSession(true, Session.AUTO_ACKNOWLEDGE);
cnx.start();
producer = session.createProducer(queue);
message = session.createTextMessage();
for (int i = 1; i <= 100000; i++) {
message.setText("Test number " + i);
producer.send(message);
if ((i % 100) == 0)session.commit();
if ((i % 1000) == 0) System.out.println(i + " messages sent");
}
session.commit();
producer.close();
session.close();
cnx.close();
}