| 1 24 package soap; 25 26 import javax.jms.*; 27 import javax.naming.*; 28 29 31 public class SoapProducer 32 { 33 static Context ictx = null; 34 35 public static void main(String [] args) throws Exception  36 { 37 System.out.println(); 38 System.out.println("Produces messages on the queue and on the topic..."); 39 40 ictx = new InitialContext(); 41 ConnectionFactory cf = (ConnectionFactory) ictx.lookup("soapCf"); 42 Queue queue = (Queue) ictx.lookup("queue"); 43 Topic topic = (Topic) ictx.lookup("topic"); 44 ictx.close(); 45 46 Connection cnx = cf.createConnection(); 47 Session sess = cnx.createSession(true, 0); 48 49 MessageProducer producer = sess.createProducer(null); 50 51 TextMessage msg = sess.createTextMessage(); 52 53 for (int i = 1; i < 11; i++) { 54 msg.setText("Soap test " + i); 55 producer.send(queue, msg); 56 producer.send(topic, msg); 57 System.out.println("SOAP test " + i); 58 } 59 60 sess.commit(); 61 cnx.close(); 62 } 63 } 64 | Popular Tags |