1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.jms;
  6. /** For application servers, <CODE>Connection</CODE> objects provide a special
  7. * facility
  8. * for creating a <CODE>ConnectionConsumer</CODE> (optional). The messages it
  9. * is to consume are
  10. * specified by a <CODE>Destination</CODE> and a message selector. In addition,
  11. * a <CODE>ConnectionConsumer</CODE> must be given a
  12. * <CODE>ServerSessionPool</CODE> to use for
  13. * processing its messages.
  14. *
  15. * <P>Normally, when traffic is light, a <CODE>ConnectionConsumer</CODE> gets a
  16. * <CODE>ServerSession</CODE> from its pool, loads it with a single message, and
  17. * starts it. As traffic picks up, messages can back up. If this happens,
  18. * a <CODE>ConnectionConsumer</CODE> can load each <CODE>ServerSession</CODE>
  19. * with more than one
  20. * message. This reduces the thread context switches and minimizes resource
  21. * use at the expense of some serialization of message processing.
  22. *
  23. * @version 1.0 - 3 August 1998
  24. * @author Mark Hapner
  25. * @author Rich Burridge
  26. *
  27. * @see javax.jms.QueueConnection#createConnectionConsumer
  28. * @see javax.jms.TopicConnection#createConnectionConsumer
  29. * @see javax.jms.TopicConnection#createDurableConnectionConsumer
  30. */
  31. public interface ConnectionConsumer {
  32. /** Gets the server session pool associated with this connection consumer.
  33. *
  34. * @return the server session pool used by this connection consumer
  35. *
  36. * @exception JMSException if the JMS provider fails to get the server
  37. * session pool associated with this consumer due
  38. * to some internal error.
  39. */
  40. ServerSessionPool
  41. getServerSessionPool() throws JMSException;
  42. /** Closes the connection consumer.
  43. *
  44. * <P>Since a provider may allocate some resources on behalf of a
  45. * connection consumer outside the Java virtual machine, clients should
  46. * close these resources when
  47. * they are not needed. Relying on garbage collection to eventually
  48. * reclaim these resources may not be timely enough.
  49. *
  50. * @exception JMSException if the JMS provider fails to release resources
  51. * on behalf of the connection consumer or fails
  52. * to close the connection consumer.
  53. */
  54. void
  55. close() throws JMSException;
  56. }