01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * 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: /** For application servers, <CODE>Connection</CODE> objects provide a special
25: * facility
26: * for creating a <CODE>ConnectionConsumer</CODE> (optional). The messages it
27: * is to consume are
28: * specified by a <CODE>Destination</CODE> and a message selector. In addition,
29: * a <CODE>ConnectionConsumer</CODE> must be given a
30: * <CODE>ServerSessionPool</CODE> to use for
31: * processing its messages.
32: *
33: * <P>Normally, when traffic is light, a <CODE>ConnectionConsumer</CODE> gets a
34: * <CODE>ServerSession</CODE> from its pool, loads it with a single message, and
35: * starts it. As traffic picks up, messages can back up. If this happens,
36: * a <CODE>ConnectionConsumer</CODE> can load each <CODE>ServerSession</CODE>
37: * with more than one
38: * message. This reduces the thread context switches and minimizes resource
39: * use at the expense of some serialization of message processing.
40: *
41: * @see javax.jms.Connection#createConnectionConsumer
42: * @see javax.jms.Connection#createDurableConnectionConsumer
43: * @see javax.jms.QueueConnection#createConnectionConsumer
44: * @see javax.jms.TopicConnection#createConnectionConsumer
45: * @see javax.jms.TopicConnection#createDurableConnectionConsumer
46: */
47:
48: public interface ConnectionConsumer {
49:
50: /** Gets the server session pool associated with this connection consumer.
51: *
52: * @return the server session pool used by this connection consumer
53: *
54: * @exception JMSException if the JMS provider fails to get the server
55: * session pool associated with this consumer due
56: * to some internal error.
57: */
58: public ServerSessionPool getServerSessionPool() throws JMSException;
59:
60: /** Closes the connection consumer.
61: *
62: * <P>Since a provider may allocate some resources on behalf of a
63: * connection consumer outside the Java virtual machine, clients should
64: * close these resources when
65: * they are not needed. Relying on garbage collection to eventually
66: * reclaim these resources may not be timely enough.
67: *
68: * @exception JMSException if the JMS provider fails to release resources
69: * on behalf of the connection consumer or fails
70: * to close the connection consumer.
71: */
72: public void close() throws JMSException;
73: }
|