1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */
22 package javax.jms;
23
24 /** A <CODE>QueueConnection</CODE> object is an active connection to a
25 * point-to-point JMS provider. A client uses a <CODE>QueueConnection</CODE>
26 * object to create one or more <CODE>QueueSession</CODE> objects
27 * for producing and consuming messages.
28 *
29 *<P>A <CODE>QueueConnection</CODE> can be used to create a
30 * <CODE>QueueSession</CODE>, from which specialized queue-related objects
31 * can be created.
32 * A more general, and recommended, approach is to use the
33 * <CODE>Connection</CODE> object.
34 *
35 *
36 * <P>The <CODE>QueueConnection</CODE> object
37 * should be used to support existing code that has already used it.
38 *
39 * <P>A <CODE>QueueConnection</CODE> cannot be used to create objects
40 * specific to the publish/subscribe domain. The
41 * <CODE>createDurableConnectionConsumer</CODE> method inherits
42 * from <CODE>Connection</CODE>, but must throw an
43 * <CODE>IllegalStateException</CODE>
44 * if used from <CODE>QueueConnection</CODE>.
45 *
46 * @see javax.jms.Connection
47 * @see javax.jms.ConnectionFactory
48 * @see javax.jms.QueueConnectionFactory
49 */
50
51 public interface QueueConnection extends Connection
52 {
53
54 /** Creates a <CODE>QueueSession</CODE> object.
55 *
56 * @param transacted indicates whether the session is transacted
57 * @param acknowledgeMode indicates whether the consumer or the
58 * client will acknowledge any messages it receives; ignored if the session
59 * is transacted. Legal values are <code>Session.AUTO_ACKNOWLEDGE</code>,
60 * <code>Session.CLIENT_ACKNOWLEDGE</code>, and
61 * <code>Session.DUPS_OK_ACKNOWLEDGE</code>.
62 *
63 * @return a newly created queue session
64 *
65 * @exception JMSException if the <CODE>QueueConnection</CODE> object fails
66 * to create a session due to some internal error or
67 * lack of support for the specific transaction
68 * and acknowledgement mode.
69 *
70 * @see Session#AUTO_ACKNOWLEDGE
71 * @see Session#CLIENT_ACKNOWLEDGE
72 * @see Session#DUPS_OK_ACKNOWLEDGE
73 */
74
75 QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException;
76
77 /** Creates a connection consumer for this connection (optional operation).
78 * This is an expert facility not used by regular JMS clients.
79 *
80 * @param queue the queue to access
81 * @param messageSelector only messages with properties matching the
82 * message selector expression are delivered. A value of null or
83 * an empty string indicates that there is no message selector
84 * for the message consumer.
85 * @param sessionPool the server session pool to associate with this
86 * connection consumer
87 * @param maxMessages the maximum number of messages that can be
88 * assigned to a server session at one time
89 *
90 * @return the connection consumer
91 *
92 * @exception JMSException if the <CODE>QueueConnection</CODE> object fails
93 * to create a connection consumer due to some
94 * internal error or invalid arguments for
95 * <CODE>sessionPool</CODE> and
96 * <CODE>messageSelector</CODE>.
97 * @exception InvalidDestinationException if an invalid queue is specified.
98 * @exception InvalidSelectorException if the message selector is invalid.
99 * @see javax.jms.ConnectionConsumer
100 */
101
102 ConnectionConsumer createConnectionConsumer(Queue queue, String messageSelector, ServerSessionPool sessionPool,
103 int maxMessages) throws JMSException;
104 }