1 23 import javax.microedition.midlet.*; 24 import javax.microedition.lcdui.*; 25 import javax.microedition.io.*; 26 27 import com.scalagent.kjoram.*; 28 import com.scalagent.kjndi.ksoap.*; 29 30 33 public class KProducer extends MIDlet { 34 35 protected void startApp() throws MIDletStateChangeException { 36 System.out.println(); 37 System.out.println("Produces messages on the queue and on the topic..."); 38 39 try { 40 SoapNamingContext ictx = new SoapNamingContext("X.X.X.X",8080); 41 ConnectionFactory cf = 42 new com.scalagent.kjoram.ksoap.SoapConnectionFactory( 43 "X.X.X.X", 8080, 360000); 44 Queue queue = (Queue) ictx.lookup("queue"); 45 Topic topic = (Topic) ictx.lookup("topic"); 46 47 com.scalagent.kjoram.Connection cnx = cf.createConnection(); 48 Session sess = cnx.createSession(true, 0); 50 51 MessageProducer producer = sess.createProducer(null); 52 53 TextMessage msg = sess.createTextMessage(); 54 55 for (int i = 1; i < 2; i++) { 56 msg.setText("kJORAM test " + i); 57 producer.send(queue, msg); 58 producer.send(topic, msg); 59 } 60 61 sess.commit(); 62 cnx.close(); 63 } catch (Exception exc) { 64 System.out.println("////////// EXCEPTION " + exc); 65 } 66 } 67 68 protected void pauseApp() { 69 } 70 71 protected void destroyApp(boolean arg0) throws MIDletStateChangeException { 72 } 73 } 74 | Popular Tags |