Package javax.jms

Examples of javax.jms.QueueReceiver


        assertEquals("Queue names should match from QueueReceiver with selector", _queue.getQueueName(), receiver.getQueue().getQueueName());
    }

    public void testCreateReceiver() throws JMSException
    {
        QueueReceiver receiver = _session.createReceiver(_queue);
        assertEquals("Queue names should match from QueueReceiver", _queue.getQueueName(), receiver.getQueue().getQueueName());

        receiver = _session.createReceiver(_queue, "abc");
        assertEquals("Queue names should match from QueueReceiver with selector", _queue.getQueueName(), receiver.getQueue().getQueueName());
    }
View Full Code Here


        QueueConnection queueConnection = factory.createQueueConnection();
        this.connection = queueConnection;
        QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        QueueSender sender = session.createSender(null); //Unidentified
        Queue receiverQueue = session.createTemporaryQueue();
        QueueReceiver receiver = session.createReceiver(receiverQueue);
        queueConnection.start();
    }
View Full Code Here

                public void run() {
                    try {
                        QueueConnection connection = createConnection();
                        QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                        Queue queue = session.createTemporaryQueue();
                        QueueReceiver consumer = session.createReceiver(queue);
                        connection.start();
                       
                       
                        if (count.incrementAndGet() >= NUMBER){
                            synchronized(count){
View Full Code Here

       */
      s_rec = qc.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
      /* start the connection */
      qc.start();
      /* Create a receiver */
      QueueReceiver qr = s_rec.createReceiver(q);
      /* Create a sender for sending messages */
      QueueSender qsender = s_send.createSender(q);
      qsender.setDisableMessageTimestamp(false);
      /* create a text message for sending */
      TextMessage msg = s_send.createTextMessage();
      /* and put some nasty text into it */
      msg.setText(TEXT);

      /* Send the message */
      qsender.send(msg);
      /* Commit the sending session */
      s_send.commit();
      /* Receive the message */
      msg = (TextMessage) qr.receiveNoWait();
      Assert.assertNotNull("message recieved", msg);
      /* Commit the session to clear the queue */
      s_rec.commit();
      /* Check, that the text of the message is still the same */
      Assert.assertEquals("text is not the same " + msg.getText(), msg
View Full Code Here

       */
      s_rec = qc.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
      /* start the connection */
      qc.start();
      /* Create a receiver */
      QueueReceiver qr = s_rec.createReceiver(q);
      /* Create a sender for sending messages */
      QueueSender qsender = s_send.createSender(q);
      qsender.setDisableMessageTimestamp(false);
      /* create a map message for sending */
      MapMessage msg = s_send.createMapMessage();
      /* put some values in it */
      msg.setByte("byte", (byte) 0);
      msg.setBoolean("boolean", true);
      msg.setChar("char", 'c');
      msg.setDouble("double", 1.11d);
      msg.setFloat("float", 1.1f);
      msg.setInt("int", 1);
      msg.setShort("short", (short) 1);
      msg.setString("string", TEXT);

      /* Send the message */
      qsender.send(msg);
      /* Commit the sending session */
      s_send.commit();
      /* Receive the message */
      msg = (MapMessage) qr.receiveNoWait();
      Assert.assertNotNull("message recieved", msg);
      /* Commit the session to clear the queue */
      s_rec.commit();
      /* Check, that the text of the message is still the same */
      Assert.assertEquals("byte", msg.getByte("byte"), (byte) 0);
View Full Code Here

       */
      s_rec = qc.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
      /* start the connection */
      qc.start();
      /* Create a receiver */
      QueueReceiver qr = s_rec.createReceiver(q);
      /* Create a sender for sending messages */
      QueueSender qsender = s_send.createSender(q);
      qsender.setDisableMessageTimestamp(false);
      /* create a text message for sending */
      StreamMessage msg = s_send.createStreamMessage();
      /* and write values into it */
      msg.writeByte((byte)0);
      msg.writeBoolean(true);
      msg.writeChar('c');
      msg.writeDouble(1.11d);
      msg.writeFloat(1.1f);
      msg.writeInt(1);
      msg.writeShort((short)1);
      msg.writeString(TEXT);

      /* Send the message */
      qsender.send(msg);
      /* Commit the sending session */
      s_send.commit();
      /* Receive the message */
      msg = (StreamMessage) qr.receiveNoWait();
     
      Assert.assertNotNull("message recieved", msg);
      /* Commit the session to clear the queue */
      s_rec.commit();
      /* Check, that the text of the message is still the same */
 
View Full Code Here

            this.queue   = queue;
            this.start();
        }

        public void run() {
            QueueReceiver rec    = null;
            QueueSender   sender = null;
            try {
                rec = this.session.createReceiver(this.queue);
                ObjectMessage msg = (ObjectMessage)rec.receive();
                ObjectMessage ret = this.session.createObjectMessage(msg.getObject());
                Queue q = (Queue)msg.getJMSReplyTo();
                sender = this.session.createSender(q);
                sender.send(ret);
                this.session.commit();
            } catch(Exception ex) {
                ex.printStackTrace();
            } finally {
                try { rec.close();    } catch(Exception ex) {}
                try { sender.close(); } catch(Exception ex) {}
            }
        }
View Full Code Here

            receiving messages, transacted and with auto-acknowledge-mode */
            s_rec   = qc.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
            /* start the connection */
            qc.start();
            /* Create a receiver */
            QueueReceiver qr = s_rec.createReceiver(q);
            /* Create a sender for sending messages */
            QueueSender qsender = s_send.createSender(q);
            qsender.setDisableMessageTimestamp(false);
            /* create a message for sending */
            Message msg = s_send.createObjectMessage(new Integer(0));
            msg.setJMSType(type);
           
            /* Send the message */
            qsender.send(msg);
            Assert.assertNotNull("sender-JMSMessageID", msg.getJMSMessageID());
            /* Commit the sending session */
            s_send.commit();
            /* Receive the message */
            msg = qr.receiveNoWait();
            Assert.assertNotNull("message recieved", msg);
            /* Commit the session to clear the queue */
            s_rec.commit();
            /* Check, if the headers are set */
            Assert.assertNull("JMSCorrelationID", msg.getJMSCorrelationID());
View Full Code Here

            receiving messages, transacted and with auto-acknowledge-mode */
            s_rec   = qc.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
            /* start the connection */
            qc.start();
            /* Create a receiver */
            QueueReceiver qr = s_rec.createReceiver(q);
            /* Create a sender for sending messages */
            QueueSender qsender = s_send.createSender(q);
            /* create a message for sending */
            Message msg = s_send.createObjectMessage(new Integer(0));
            msg.setStringProperty(PROP1, VAL1);
            msg.setStringProperty(PROP2, VAL2);
            msg.setStringProperty(PROP3, VAL3);
            msg.setLongProperty(PROP4, VAL4);
            msg.setFloatProperty(PROP5, VAL5);
            msg.setShortProperty(PROP6, VAL6);
            msg.setBooleanProperty(PROP7, VAL7);
            msg.setIntProperty(PROP8, VAL8);
            msg.setDoubleProperty(PROP9, VAL9);
            /* Send the message */
            qsender.send(msg);
            /* Commit the sending session */
            s_send.commit();
            /* Receive the message */
            msg = qr.receiveNoWait();
            /* Commit the session to clear the queue */
            s_rec.commit();
            /* Check, if the headers are set */
            Assert.assertEquals(PROP1, VAL1, msg.getStringProperty(PROP1));
            Assert.assertEquals(PROP2, VAL2, msg.getStringProperty(PROP2));
View Full Code Here

            s_rec   = qc.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
            /* start the connection */
            qc.start();
            /* Create a receiver and set a message-listener. This will be used to see,
               whether messages are delivered before the session is commited */
            QueueReceiver qr = s_rec.createReceiver(q);
            ML ml = new ML();
            qr.setMessageListener(ml);
            /* Create a sender for sending messages */
            QueueSender qsender = s_send.createSender(q);
            /* create a couple of messages for sending */
            final int num = 5;
            Message[] msgs = new Message[num];
View Full Code Here

TOP

Related Classes of javax.jms.QueueReceiver

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.