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>QueueSender</CODE> object to send messages to a queue.
  7. *
  8. * <P>Normally, the <CODE>Queue</CODE> is specified when a
  9. * <CODE>QueueSender</CODE> is created. In this case, an attempt to use
  10. * the <CODE>send</CODE> methods for an unidentified
  11. * <CODE>QueueSender</CODE> will throw a
  12. * <CODE>java.lang.UnsupportedOperationException</CODE>.
  13. *
  14. * <P>If the <CODE>QueueSender</CODE> is created with an unidentified
  15. * <CODE>Queue</CODE>, an attempt to use the <CODE>send</CODE> methods that
  16. * assume that the <CODE>Queue</CODE> has been identified will throw a
  17. * <CODE>java.lang.UnsupportedOperationException</CODE>.
  18. *
  19. * <P>During the execution of its <CODE>send</CODE> method, a message
  20. * must not be changed by other threads within the client.
  21. * If the message is modified, the result of the <CODE>send</CODE> is
  22. * undefined.
  23. *
  24. * <P>After sending a message, a client may retain and modify it
  25. * without affecting the message that has been sent. The same message
  26. * object may be sent multiple times.
  27. *
  28. * <P>The following message headers are set as part of sending a
  29. * message: <code>JMSDestination</code>, <code>JMSDeliveryMode</code>,
  30. * <code>JMSExpiration</code>, <code>JMSPriority</code>,
  31. * <code>JMSMessageID</code> and <code>JMSTimeStamp</code>.
  32. * When the message is sent, the values of these headers are ignored.
  33. * After the completion of the <CODE>send</CODE>, the headers hold the values
  34. * specified by the method sending the message. It is possible for the
  35. * <code>send</code> method not to set <code>JMSMessageID</code> and
  36. * <code>JMSTimeStamp</code> if the
  37. * setting of these headers is explicitly disabled by the
  38. * <code>MessageProducer.setDisableMessageID</code> or
  39. * <code>MessageProducer.setDisableMessageTimestamp</code> method.
  40. *
  41. * @version 1.0 - 4 August 1998
  42. * @author Mark Hapner
  43. * @author Rich Burridge
  44. *
  45. * @see javax.jms.MessageProducer
  46. * @see javax.jms.QueueSession#createSender(Queue)
  47. */
  48. public interface QueueSender extends MessageProducer {
  49. /** Gets the queue associated with this <CODE>QueueSender</CODE>.
  50. *
  51. * @return this sender's queue
  52. *
  53. * @exception JMSException if the JMS provider fails to get the queue for
  54. * this <CODE>QueueSender</CODE>
  55. * due to some internal error.
  56. */
  57. Queue
  58. getQueue() throws JMSException;
  59. /** Sends a message to the queue. Uses the <CODE>QueueSender</CODE>'s
  60. * default delivery mode, priority, and time to live.
  61. *
  62. * @param message the message to send
  63. *
  64. * @exception JMSException if the JMS provider fails to send the message
  65. * due to some internal error.
  66. * @exception MessageFormatException if an invalid message is specified.
  67. * @exception InvalidDestinationException if a client uses
  68. * this method with a <CODE>QueueSender</CODE> with
  69. * an invalid queue.
  70. * @exception java.lang.UnsupportedOperationException if a client uses this
  71. * method with a <CODE>QueueSender</CODE> that did
  72. * not specify a queue at creation time.
  73. *
  74. * @see javax.jms.MessageProducer#getDeliveryMode()
  75. * @see javax.jms.MessageProducer#getTimeToLive()
  76. * @see javax.jms.MessageProducer#getPriority()
  77. */
  78. void
  79. send(Message message) throws JMSException;
  80. /** Sends a message to the queue, specifying delivery mode, priority, and
  81. * time to live.
  82. *
  83. * @param message the message to send
  84. * @param deliveryMode the delivery mode to use
  85. * @param priority the priority for this message
  86. * @param timeToLive the message's lifetime (in milliseconds)
  87. *
  88. * @exception JMSException if the JMS provider fails to send the message
  89. * due to some internal error.
  90. * @exception MessageFormatException if an invalid message is specified.
  91. * @exception InvalidDestinationException if a client uses
  92. * this method with a <CODE>QueueSender</CODE> with
  93. * an invalid queue.
  94. * @exception java.lang.UnsupportedOperationException if a client uses this
  95. * method with a <CODE>QueueSender</CODE> that did
  96. * not specify a queue at creation time.
  97. */
  98. void
  99. send(Message message,
  100. int deliveryMode,
  101. int priority,
  102. long timeToLive) throws JMSException;
  103. /** Sends a message to a queue for an unidentified message producer.
  104. * Uses the <CODE>QueueSender</CODE>'s default delivery mode, priority,
  105. * and time to live.
  106. *
  107. * <P>Typically, a message producer is assigned a queue at creation
  108. * time; however, the JMS API also supports unidentified message producers,
  109. * which require that the queue be supplied every time a message is
  110. * sent.
  111. *
  112. * @param queue the queue to send this message to
  113. * @param message the message to send
  114. *
  115. * @exception JMSException if the JMS provider fails to send the message
  116. * due to some internal error.
  117. * @exception MessageFormatException if an invalid message is specified.
  118. * @exception InvalidDestinationException if a client uses
  119. * this method with an invalid queue.
  120. *
  121. * @see javax.jms.MessageProducer#getDeliveryMode()
  122. * @see javax.jms.MessageProducer#getTimeToLive()
  123. * @see javax.jms.MessageProducer#getPriority()
  124. */
  125. void
  126. send(Queue queue, Message message) throws JMSException;
  127. /** Sends a message to a queue for an unidentified message producer,
  128. * specifying delivery mode, priority and time to live.
  129. *
  130. * <P>Typically, a message producer is assigned a queue at creation
  131. * time; however, the JMS API also supports unidentified message producers,
  132. * which require that the queue be supplied every time a message is
  133. * sent.
  134. *
  135. * @param queue the queue to send this message to
  136. * @param message the message to send
  137. * @param deliveryMode the delivery mode to use
  138. * @param priority the priority for this message
  139. * @param timeToLive the message's lifetime (in milliseconds)
  140. *
  141. * @exception JMSException if the JMS provider fails to send the message
  142. * due to some internal error.
  143. * @exception MessageFormatException if an invalid message is specified.
  144. * @exception InvalidDestinationException if a client uses
  145. * this method with an invalid queue.
  146. */
  147. void
  148. send(Queue queue,
  149. Message message,
  150. int deliveryMode,
  151. int priority,
  152. long timeToLive) throws JMSException;
  153. }