1 /***
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18
19 package org.codehaus.activemq;
20
21 import org.codehaus.activemq.message.ActiveMQDestination;
22
23 import javax.jms.JMSException;
24 import javax.jms.Queue;
25 import javax.jms.QueueReceiver;
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 {
60
61 /***
62 * @param theSession
63 * @param dest
64 * @param selector
65 * @param cnum
66 * @param prefetch
67 * @throws JMSException
68 */
69 protected ActiveMQQueueReceiver(ActiveMQSession theSession,
70 ActiveMQDestination dest, String selector, int cnum, int prefetch)
71 throws JMSException {
72 super(theSession, dest, "", selector, cnum, prefetch, false, false);
73 }
74
75 /***
76 * Gets the <CODE>Queue</CODE> associated with this queue receiver.
77 *
78 * @return this receiver's <CODE>Queue</CODE>
79 * @throws JMSException if the JMS provider fails to get the queue for this queue
80 * receiver due to some internal error.
81 */
82
83 public Queue getQueue() throws JMSException {
84 checkClosed();
85 return (Queue) super.getDestination();
86 }
87 }