Package javax.jms

Examples of javax.jms.MessageConsumer


                                    this + " createSubscriber(" + topic +
                                    ", " + selector +
                                    ", " + noLocal + ")");

    checkValidity();
    MessageConsumer cons = sess.createConsumer(topic, selector, noLocal);
    return new OutboundSubscriber(topic, noLocal, cons, this);
  }
View Full Code Here


      AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
                                    this + " createSubscriber(" + topic +
                                    ", " + selector + ")");

    checkValidity();
    MessageConsumer cons = sess.createConsumer(topic, selector);
    return new OutboundSubscriber(topic, false, cons, this);
  }
View Full Code Here

    System.out.println("Trace2");

    Connection cnx = cf.createConnection();
    Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer cons = sess.createConsumer(queue);

    System.out.println("Listens to the MailQueue...");
    System.out.println("hit a key to stop.");

    cons.setMessageListener(new MsgListener("Queue listener"));

    cnx.start();

    System.in.read();
    cnx.close();
View Full Code Here

    ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
    ictx.close();

    Connection cnx = cf.createConnection();
    Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer recv = sess.createConsumer(queue);
    // MessageConsumer subs = sess.createConsumer(topic);

    recv.setMessageListener(new MsgListener("Collector Queue listener"));
    // subs.setMessageListener(new MsgListener("Colector Topic listener"));

    cnx.start();

    System.in.read();
View Full Code Here

    ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
    ictx.close();

    Connection cnx = cf.createConnection();
    Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer subs = sess.createConsumer(topic);

    subs.setMessageListener(new MonitorMsgListener());

    cnx.start();

    System.in.read();
    cnx.close();
View Full Code Here

    ictx.close();

    Connection cnx = cf.createConnection("anonymous", "anonymous");

    Session session = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = session.createConsumer(dmq);

    cnx.start();
   
    for (int i=0; i<3; i++) {
      TextMessage msg = (TextMessage) consumer.receive();
      System.out.println("\nreceives: \"" + msg.getText() + "\", " +
                         "JMS_JORAM_ERRORCOUNT=" + msg.getIntProperty("JMS_JORAM_ERRORCOUNT"));
      System.out.println("JMS_JORAM_ERRORCAUSE_1=" + msg.getStringProperty("JMS_JORAM_ERRORCAUSE_1") + ", " +
                         "JMS_JORAM_ERRORCODE_1=" + msg.getStringProperty("JMS_JORAM_ERRORCODE_1"));
      System.out.println("JMSXDeliveryCount=" + msg.getIntProperty("JMSXDeliveryCount"));
View Full Code Here

    Connection cnx = cf.createConnection();
    Session prodSession = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Session consSession = cnx.createSession(true, 0);
   
    MessageProducer producer = prodSession.createProducer(null);
    MessageConsumer consumer = consSession.createConsumer(queue1);

    cnx.start();

    // Producing messages with a very short time to live: 20 ms.
    System.out.println("Sends Message1 with a very short time to live");
    TextMessage msg = prodSession.createTextMessage("Message1");
    producer.send(queue1, msg, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, 20);
   
    // Waiting for the message to be expired.
    System.out.println("Waits for the message to be expired");
    Thread.sleep(100);

    msg = (TextMessage) consumer.receiveNoWait();
    System.out.println("receives: " + msg);
   
    // Producing "undeliverable" messages
    System.out.println("Send Message2");  
    msg = prodSession.createTextMessage("Message2");
    producer.send(queue1, msg);
   
    msg = (TextMessage) consumer.receive();
    System.out.println("Receives: " + msg.getText() + " then deny it!");
    consSession.rollback();
   
    msg = (TextMessage) consumer.receive();
    System.out.println("Receives: " + msg.getText() + " then deny it!");
    consSession.rollback();
       
    // Producing "forbidden" messages
    System.out.println("Send Message3");  
View Full Code Here

    Topic topic = (Topic) jndiCtx.lookup("topic");
    jndiCtx.close();
   
    Connection cnx = tcf.createConnection("anonymous", "anonymous");
    Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer sub = sess.createConsumer(topic);

    sub.setMessageListener(new Listener());

    cnx.start();

    System.in.read();
View Full Code Here

    ictx.close();

    Connection cnx = cf.createConnection();
    Session qSess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);

    MessageConsumer qConsumer = qSess.createConsumer(queue);
    cnx.start();

    TextMessage msg;

    for (int i = 0; i < 10; i++) {
      msg = (TextMessage) qConsumer.receive();
      System.out.println("Message received from queue: " + msg.getText());
    }

    cnx.close();
  }
View Full Code Here

    ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
    ictx.close();

    Connection cnx = cf.createConnection();
    Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer recv = sess.createConsumer(queue);
    Message msg;

    cnx.start();

    msg = recv.receive();
     
    String u = msg.getStringProperty("url");
    System.out.println("url = " + u);
    System.out.println("crc=" + msg.getLongProperty("crc"));
    System.out.println("ack=" + msg.getBooleanProperty("ack"));
View Full Code Here

TOP

Related Classes of javax.jms.MessageConsumer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.