KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > ActiveMQQueueReceiver


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq;
19
20 import org.apache.activemq.command.ActiveMQDestination;
21 import org.apache.activemq.command.ConsumerId;
22
23 import javax.jms.JMSException JavaDoc;
24 import javax.jms.Queue JavaDoc;
25 import javax.jms.QueueReceiver JavaDoc;
26
27 /**
28  * A client uses a <CODE>QueueReceiver</CODE> object to receive messages that
29  * have been delivered to a queue.
30  * <p/>
31  * <P>
32  * Although it is possible to have multiple <CODE>QueueReceiver</CODE> s for
33  * the same queue, the JMS API does not define how messages are distributed
34  * between the <CODE>QueueReceiver</CODE>s.
35  * <p/>
36  * <P>
37  * If a <CODE>QueueReceiver</CODE> specifies a message selector, the messages
38  * that are not selected remain on the queue. By definition, a message selector
39  * allows a <CODE>QueueReceiver</CODE> to skip messages. This means that when
40  * the skipped messages are eventually read, the total ordering of the reads
41  * does not retain the partial order defined by each message producer. Only
42  * <CODE>QueueReceiver</CODE> s without a message selector will read messages
43  * in message producer order.
44  * <p/>
45  * <P>
46  * Creating a <CODE>MessageConsumer</CODE> provides the same features as
47  * creating a <CODE>QueueReceiver</CODE>. A <CODE>MessageConsumer</CODE>
48  * object is recommended for creating new code. The <CODE>QueueReceiver
49  * </CODE> is provided to support existing code.
50  *
51  * @see javax.jms.Session#createConsumer(javax.jms.Destination, String)
52  * @see javax.jms.Session#createConsumer(javax.jms.Destination)
53  * @see javax.jms.QueueSession#createReceiver(Queue, String)
54  * @see javax.jms.QueueSession#createReceiver(Queue)
55  * @see javax.jms.MessageConsumer
56  */

57
58 public class ActiveMQQueueReceiver extends ActiveMQMessageConsumer implements
59         QueueReceiver JavaDoc {
60
61     /**
62      * @param theSession
63      * @param value
64      * @param destination
65      * @param messageSelector
66      * @param prefetch
67      * @param asyncDispatch
68      * @throws JMSException
69      */

70     protected ActiveMQQueueReceiver(ActiveMQSession theSession,
71                                     ConsumerId consumerId, ActiveMQDestination destination, String JavaDoc selector, int prefetch, int maximumPendingMessageCount, boolean asyncDispatch)
72             throws JMSException JavaDoc {
73         super(theSession, consumerId, destination, null, selector, prefetch, maximumPendingMessageCount, false, false, asyncDispatch);
74     }
75
76     /**
77      * Gets the <CODE>Queue</CODE> associated with this queue receiver.
78      *
79      * @return this receiver's <CODE>Queue</CODE>
80      * @throws JMSException if the JMS provider fails to get the queue for this queue
81      * receiver due to some internal error.
82      */

83
84     public Queue JavaDoc getQueue() throws JMSException JavaDoc {
85         checkClosed();
86         return (Queue JavaDoc) super.getDestination();
87     }
88     
89 }
90
Popular Tags