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. /** A client uses a <CODE>TopicSubscriber</CODE> object to receive messages that
  7. * have been published to a topic. A <CODE>TopicSubscriber</CODE> object is the
  8. * publish/subscribe form of a message consumer.
  9. *
  10. * <P>A <CODE>TopicSession</CODE> allows the creation of multiple
  11. * <CODE>TopicSubscriber</CODE> objects per topic. It will deliver each
  12. * message for a topic to each
  13. * subscriber eligible to receive it. Each copy of the message
  14. * is treated as a completely separate message. Work done on one copy has
  15. * no effect on the others; acknowledging one does not acknowledge the
  16. * others; one message may be delivered immediately, while another waits
  17. * for its subscriber to process messages ahead of it.
  18. *
  19. * <P>Regular <CODE>TopicSubscriber</CODE> objects are not durable. They
  20. * receive only messages that are published while they are active.
  21. *
  22. * <P>Messages filtered out by a subscriber's message selector will never
  23. * be delivered to the subscriber. From the subscriber's perspective, they
  24. * do not exist.
  25. *
  26. * <P>In some cases, a connection may both publish and subscribe to a topic.
  27. * The subscriber <CODE>NoLocal</CODE> attribute allows a subscriber to inhibit
  28. * the
  29. * delivery of messages published by its own connection.
  30. *
  31. * <P>If a client needs to receive all the messages published on a topic,
  32. * including the ones published while the subscriber is inactive, it uses
  33. * a durable <CODE>TopicSubscriber</CODE>. The JMS provider retains a record of
  34. * this durable
  35. * subscription and insures that all messages from the topic's publishers
  36. * are retained until they are acknowledged by this durable
  37. * subscriber or they have expired.
  38. *
  39. * <P>Sessions with durable subscribers must always provide the same client
  40. * identifier. In addition, each client must specify a name that uniquely
  41. * identifies (within client identifier) each durable subscription it creates.
  42. * Only one session at a time can have a <CODE>TopicSubscriber</CODE> for a
  43. * particular durable subscription.
  44. *
  45. * <P>A client can change an existing durable subscription by creating a
  46. * durable <CODE>TopicSubscriber</CODE> with the same name and a new topic
  47. * and/or message
  48. * selector. Changing a durable subscription is equivalent to unsubscribing
  49. * (deleting) the old one and creating a new one.
  50. *
  51. * <P><CODE>TopicSession</CODE>s provide the <CODE>unsubscribe</CODE> method
  52. * for deleting a durable
  53. * subscription created by their client. This method deletes the state being
  54. * maintained on behalf of the subscriber by its provider.
  55. *
  56. * @version 1.0 - 7 August 1998
  57. * @author Mark Hapner
  58. * @author Rich Burridge
  59. *
  60. * @see javax.jms.TopicSession
  61. * @see javax.jms.TopicSession#createSubscriber(Topic)
  62. * @see javax.jms.TopicSession#createSubscriber(Topic, String, boolean)
  63. * @see javax.jms.TopicSession#createDurableSubscriber(Topic, String)
  64. * @see javax.jms.TopicSession#createDurableSubscriber(Topic, String, String, boolean)
  65. * @see javax.jms.MessageConsumer
  66. */
  67. public interface TopicSubscriber extends MessageConsumer {
  68. /** Gets the <CODE>Topic</CODE> associated with this subscriber.
  69. *
  70. * @return this subscriber's <CODE>Topic</CODE>
  71. *
  72. * @exception JMSException if the JMS provider fails to get the topic for
  73. * this topic subscriber
  74. * due to some internal error.
  75. */
  76. Topic
  77. getTopic() throws JMSException;
  78. /** Gets the <CODE>NoLocal</CODE> attribute for this subscriber.
  79. * The default value for this attribute is false.
  80. *
  81. * @return true if locally published messages are being inhibited
  82. *
  83. * @exception JMSException if the JMS provider fails to get the
  84. * <CODE>NoLocal</CODE> attribute for
  85. * this topic subscriber
  86. * due to some internal error.
  87. */
  88. boolean
  89. getNoLocal() throws JMSException;
  90. }