001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. 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 package org.apache.activemq;
018
019 import javax.jms.JMSException;
020 import javax.jms.Queue;
021 import javax.jms.QueueReceiver;
022
023 import org.apache.activemq.command.ActiveMQDestination;
024 import org.apache.activemq.command.ConsumerId;
025
026 /**
027 * A client uses a <CODE>QueueReceiver</CODE> object to receive messages that
028 * have been delivered to a queue. <p/>
029 * <P>
030 * Although it is possible to have multiple <CODE>QueueReceiver</CODE> s for
031 * the same queue, the JMS API does not define how messages are distributed
032 * between the <CODE>QueueReceiver</CODE>s. <p/>
033 * <P>
034 * If a <CODE>QueueReceiver</CODE> specifies a message selector, the messages
035 * that are not selected remain on the queue. By definition, a message selector
036 * allows a <CODE>QueueReceiver</CODE> to skip messages. This means that when
037 * the skipped messages are eventually read, the total ordering of the reads
038 * does not retain the partial order defined by each message producer. Only
039 * <CODE>QueueReceiver</CODE> s without a message selector will read messages
040 * in message producer order. <p/>
041 * <P>
042 * Creating a <CODE>MessageConsumer</CODE> provides the same features as
043 * creating a <CODE>QueueReceiver</CODE>. A <CODE>MessageConsumer</CODE>
044 * object is recommended for creating new code. The <CODE>QueueReceiver
045 * </CODE>
046 * is provided to support existing code.
047 *
048 * @see javax.jms.Session#createConsumer(javax.jms.Destination, String)
049 * @see javax.jms.Session#createConsumer(javax.jms.Destination)
050 * @see javax.jms.QueueSession#createReceiver(Queue, String)
051 * @see javax.jms.QueueSession#createReceiver(Queue)
052 * @see javax.jms.MessageConsumer
053 */
054
055 public class ActiveMQQueueReceiver extends ActiveMQMessageConsumer implements QueueReceiver {
056
057 /**
058 * @param theSession
059 * @param value
060 * @param destination
061 * @param messageSelector
062 * @param prefetch
063 * @param asyncDispatch
064 * @throws JMSException
065 */
066 protected ActiveMQQueueReceiver(ActiveMQSession theSession, ConsumerId consumerId,
067 ActiveMQDestination destination, String selector, int prefetch,
068 int maximumPendingMessageCount, boolean asyncDispatch)
069 throws JMSException {
070 super(theSession, consumerId, destination, null, selector, prefetch, maximumPendingMessageCount,
071 false, false, asyncDispatch, null);
072 }
073
074 /**
075 * Gets the <CODE>Queue</CODE> associated with this queue receiver.
076 *
077 * @return this receiver's <CODE>Queue</CODE>
078 * @throws JMSException if the JMS provider fails to get the queue for this
079 * queue receiver due to some internal error.
080 */
081
082 public Queue getQueue() throws JMSException {
083 checkClosed();
084 return (Queue)super.getDestination();
085 }
086
087 }