001 /**
002 *
003 * Copyright 2004 Protique Ltd
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 *
017 **/
018
019 package org.activemq;
020
021 import org.activemq.message.ActiveMQDestination;
022
023 import javax.jms.JMSException;
024 import javax.jms.Queue;
025 import javax.jms.QueueReceiver;
026
027 /**
028 * A client uses a <CODE>QueueReceiver</CODE> object to receive messages that
029 * have been delivered to a queue.
030 * <p/>
031 * <P>
032 * Although it is possible to have multiple <CODE>QueueReceiver</CODE> s for
033 * the same queue, the JMS API does not define how messages are distributed
034 * between the <CODE>QueueReceiver</CODE>s.
035 * <p/>
036 * <P>
037 * If a <CODE>QueueReceiver</CODE> specifies a message selector, the messages
038 * that are not selected remain on the queue. By definition, a message selector
039 * allows a <CODE>QueueReceiver</CODE> to skip messages. This means that when
040 * the skipped messages are eventually read, the total ordering of the reads
041 * does not retain the partial order defined by each message producer. Only
042 * <CODE>QueueReceiver</CODE> s without a message selector will read messages
043 * in message producer order.
044 * <p/>
045 * <P>
046 * Creating a <CODE>MessageConsumer</CODE> provides the same features as
047 * creating a <CODE>QueueReceiver</CODE>. A <CODE>MessageConsumer</CODE>
048 * object is recommended for creating new code. The <CODE>QueueReceiver
049 * </CODE> is provided to support existing code.
050 *
051 * @see javax.jms.Session#createConsumer(javax.jms.Destination, String)
052 * @see javax.jms.Session#createConsumer(javax.jms.Destination)
053 * @see javax.jms.QueueSession#createReceiver(Queue, String)
054 * @see javax.jms.QueueSession#createReceiver(Queue)
055 * @see javax.jms.MessageConsumer
056 */
057
058 public class ActiveMQQueueReceiver extends ActiveMQMessageConsumer implements
059 QueueReceiver {
060
061 /**
062 * @param theSession
063 * @param dest
064 * @param selector
065 * @param cnum
066 * @param prefetch
067 * @throws JMSException
068 */
069 protected ActiveMQQueueReceiver(ActiveMQSession theSession,
070 ActiveMQDestination dest, String selector, int cnum, int prefetch)
071 throws JMSException {
072 super(theSession, dest, "", selector, cnum, prefetch, false, false);
073 }
074
075 /**
076 * Gets the <CODE>Queue</CODE> associated with this queue receiver.
077 *
078 * @return this receiver's <CODE>Queue</CODE>
079 * @throws JMSException if the JMS provider fails to get the queue for this queue
080 * receiver due to some internal error.
081 */
082
083 public Queue getQueue() throws JMSException {
084 checkClosed();
085 return (Queue) super.getDestination();
086 }
087 }