All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.jms.MessageProducer Maven / Gradle / Ivy

The newest version!
/**
 * Copyright 2013 ScalAgent Distributed Technologies
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  ---------------------------------------------------------------------
 *  $Id: MessageProducer.java 6347 2013-03-13 08:52:02Z tachker $
 *  ---------------------------------------------------------------------
 */

package javax.jms;

/**
 * A client uses a {@code MessageProducer} object to send messages to a
 * destination. A {@code MessageProducer} object is created by passing a
 * {@code Destination} object to a message-producer creation method supplied by
 * a session.
 * 
 * A JMS provider should do its best to expire messages accurately; however, the
 * JMS API does not define the accuracy provided.
 * 
 * @see javax.jms.TopicPublisher
 * @see javax.jms.QueueSender
 * @see javax.jms.Session#createProducer
 * 
 * @version JMS 2.0
 * @since JMS 1.0
 * 
 */

public interface MessageProducer extends AutoCloseable {

  /**
   * Specify whether message IDs may be disabled.
   * 
   * @param value
   *          indicates if message IDs may be disabled
   * 
   * @exception JMSException
   *              if the JMS provider fails to set message ID to disabled due to
   *              some internal error.
   */
  void setDisableMessageID(boolean value) throws JMSException;

  /**
   * Gets an indication of whether message IDs are disabled.
   * 
   * @return an indication of whether message IDs are disabled
   * 
   * @exception JMSException
   *              if the JMS provider fails to determine if message IDs are
   *              disabled due to some internal error.
   */
  boolean getDisableMessageID() throws JMSException;

  /**
   * Specify whether message timestamps may be disabled.
   * 
   * Message timestamps are enabled by default.
   * 
   * @param value
   *          indicates whether message timestamps may be disabled
   * 
   * @exception JMSException
   *              if the JMS provider fails to set timestamps to disabled due to
   *              some internal error.
   */
  void setDisableMessageTimestamp(boolean value) throws JMSException;

  /**
   * Gets an indication of whether message timestamps are disabled.
   * 
   * @return an indication of whether message timestamps are disabled
   * 
   * @exception JMSException
   *              if the JMS provider fails to determine if timestamps are
   *              disabled due to some internal error.
   */
  boolean getDisableMessageTimestamp() throws JMSException;

  /**
   * Sets the producer's default delivery mode.
   * 
   * @param deliveryMode
   *          the message delivery mode for this message producer; legal values
   *          are {@code DeliveryMode.NON_PERSISTENT} and
   *          {@code DeliveryMode.PERSISTENT}
   * 
   * @exception JMSException
   *              if the JMS provider fails to set the delivery mode due to some
   *              internal error.
   * 
   * @see javax.jms.MessageProducer#getDeliveryMode
   * @see javax.jms.DeliveryMode#NON_PERSISTENT
   * @see javax.jms.DeliveryMode#PERSISTENT
   * @see javax.jms.Message#DEFAULT_DELIVERY_MODE
   */

  void setDeliveryMode(int deliveryMode) throws JMSException;

  /**
   * Gets the producer's default delivery mode.
   * 
   * @return the message delivery mode for this message producer
   * 
   * @exception JMSException
   *              if the JMS provider fails to get the delivery mode due to some
   *              internal error.
   * 
   * @see javax.jms.MessageProducer#setDeliveryMode
   */

  int getDeliveryMode() throws JMSException;

  /**
   * Sets the producer's default priority.
   * 
   * @param defaultPriority
   *          the message priority for this message producer; must be a value
   *          between 0 and 9
   * 
   * 
   * @exception JMSException
   *              if the JMS provider fails to set the priority due to some
   *              internal error.
   * 
   * @see javax.jms.MessageProducer#getPriority
   * @see javax.jms.Message#DEFAULT_PRIORITY
   */

  void setPriority(int defaultPriority) throws JMSException;

  /**
   * Gets the producer's default priority.
   * 
   * @return the message priority for this message producer
   * 
   * @exception JMSException
   *              if the JMS provider fails to get the priority due to some
   *              internal error.
   * 
   * @see javax.jms.MessageProducer#setPriority
   */

  int getPriority() throws JMSException;

  /**
   * Sets the default length of time in milliseconds from its dispatch time that
   * a produced message should be retained by the message system.
   * 
   * @param timeToLive
   *          the message time to live in milliseconds; zero is unlimited
   * 
   * @exception JMSException
   *              if the JMS provider fails to set the time to live due to some
   *              internal error.
   * 
   * @see javax.jms.MessageProducer#getTimeToLive
   * @see javax.jms.Message#DEFAULT_TIME_TO_LIVE
   */

  void setTimeToLive(long timeToLive) throws JMSException;

  /**
   * Gets the default length of time in milliseconds from its dispatch time that
   * a produced message should be retained by the message system.
   * 
   * @return the message time to live in milliseconds; zero is unlimited
   * 
   * @exception JMSException
   *              if the JMS provider fails to get the time to live due to some
   *              internal error.
   * 
   * @see javax.jms.MessageProducer#setTimeToLive
   */

  long getTimeToLive() throws JMSException;

  /**
   * Sets the minimum length of time in milliseconds that must elapse after a
   * message is sent before the JMS provider may deliver the message to a
   * consumer. deliveryDelay is set to zero by default.
   * 
   * @param deliveryDelay
   *          the delivery delay in milliseconds.
   * 
   * @exception JMSException
   *              if the JMS provider fails to set the delivery delay due to
   *              some internal error.
   * 
   * @see javax.jms.MessageProducer#getDeliveryDelay
   * @see javax.jms.Message#DEFAULT_DELIVERY_DELAY
   * 
   * @since JMS 2.0
   */

  void setDeliveryDelay(long deliveryDelay) throws JMSException;

  /**
   * Gets the minimum length of time in milliseconds that must elapse after a
   * message is sent before the JMS provider may deliver the message to a
   * consumer.
   * 
   * @return the delivery delay in milliseconds.
   * 
   * @exception JMSException
   *              if the JMS provider fails to get the delivery delay due to
   *              some internal error.
   * 
   * @see javax.jms.MessageProducer#setDeliveryDelay
   * 
   * @since JMS 2.0
   */

  long getDeliveryDelay() throws JMSException;

  /**
   * Gets the destination associated with this {@code MessageProducer}.
   * 
   * @return this producer's {@code Destination}
   * 
   * @exception JMSException
   *              if the JMS provider fails to get the destination for this
   *              {@code MessageProducer} due to some internal error.
   * 
   * @since JMS 1.1
   */

  Destination getDestination() throws JMSException;

  /**
   * Closes the message producer.
   * 
   * @exception IllegalStateException
   *              this method has been called by a CompletionListener
   *              callback method on its own MessageProducer
   * @exception JMSException
   *              if the JMS provider fails to close the producer due to some
   *              internal error.
   */

  void close() throws JMSException;

  /**
   * Sends a message using the {@code MessageProducer}'s default delivery mode,
   * priority, and time to live.
   * 
   * @param message
   *          the message to send
   * 
   * @exception JMSException
   *              if the JMS provider fails to send the message due to some
   *              internal error.
   * @exception MessageFormatException
   *              if an invalid message is specified.
   * @exception InvalidDestinationException
   *              if a client uses this method with a {@code MessageProducer}
   *              with an invalid destination.
   * @exception java.lang.UnsupportedOperationException
   *              if a client uses this method with a {@code MessageProducer}
   *              that did not specify a destination at creation time.
   * 
   * @see javax.jms.Session#createProducer
   * 
   * @since JMS 1.1
   */

  void send(Message message) throws JMSException;

  /**
   * Sends a message, specifying delivery mode, priority, and time to live.
   * 
   * @param message
   *          the message to send
   * @param deliveryMode
   *          the delivery mode to use
   * @param priority
   *          the priority for this message
   * @param timeToLive
   *          the message's lifetime (in milliseconds)
   * 
   * @exception JMSException
   *              if the JMS provider fails to send the message due to some
   *              internal error.
   * @exception MessageFormatException
   *              if an invalid message is specified.
   * @exception InvalidDestinationException
   *              if a client uses this method with a {@code MessageProducer}
   *              with an invalid destination.
   * @exception java.lang.UnsupportedOperationException
   *              if a client uses this method with a {@code MessageProducer}
   *              that did not specify a destination at creation time.
   * 
   * @see javax.jms.Session#createProducer
   * @since JMS 1.1
   */

  void send(Message message, int deliveryMode, int priority, long timeToLive)
      throws JMSException;

  /**
   * Sends a message to a destination for an unidentified message producer using
   * the {@code MessageProducer}'s default delivery mode, priority, and time to
   * live.
   * 
   * @param destination
   *          the destination to send this message to
   * @param message
   *          the message to send
   * 
   * @exception JMSException
   *              if the JMS provider fails to send the message due to some
   *              internal error.
   * @exception MessageFormatException
   *              if an invalid message is specified.
   * @exception InvalidDestinationException
   *              if a client uses this method with an invalid destination.
   * @exception java.lang.UnsupportedOperationException
   *              if a client uses this method with a {@code MessageProducer}
   *              that specified a destination at creation time.
   * 
   * @see javax.jms.Session#createProducer
   * @since JMS 1.1
   */

  void send(Destination destination, Message message) throws JMSException;

  /**
   * Sends a message to a destination for an unidentified message producer,
   * specifying delivery mode, priority and time to live.
   * 
   * @param destination
   *          the destination to send this message to
   * @param message
   *          the message to send
   * @param deliveryMode
   *          the delivery mode to use
   * @param priority
   *          the priority for this message
   * @param timeToLive
   *          the message's lifetime (in milliseconds)
   * 
   * @exception JMSException
   *              if the JMS provider fails to send the message due to some
   *              internal error.
   * @exception MessageFormatException
   *              if an invalid message is specified.
   * @exception InvalidDestinationException
   *              if a client uses this method with an invalid destination.
   * @exception java.lang.UnsupportedOperationException
   *              if a client uses this method with a {@code MessageProducer}
   *              that specified a destination at creation time.
   * 
   * @see javax.jms.Session#createProducer
   * @since JMS 1.1
   */

  void send(Destination destination, Message message, int deliveryMode,
      int priority, long timeToLive) throws JMSException;

  /**
   * Sends a message using the {@code MessageProducer}'s default delivery mode,
   * priority, and time to live, performing part of the work involved in sending
   * the message in a separate thread and notifying the specified
   * CompletionListener when the operation has completed. JMS refers to
   * this as an "asynchronous send".
   * 
   * @param message
   *          the message to send
   * @param completionListener
   *          a {@code CompletionListener} to be notified when the send has
   *          completed
   * 
   * @exception JMSException
   *              if an internal error occurs
   * @exception MessageFormatException
   *              if an invalid message is specified.
   * @exception InvalidDestinationException
   *              if a client uses this method with a {@code MessageProducer}
   *              with an invalid destination.
   * @exception java.lang.IllegalArgumentException
   *              if the specified {@code CompletionListener} is null
   * @exception java.lang.UnsupportedOperationException
   *              if a client uses this method with a {@code MessageProducer}
   *              that did not specify a destination at creation time.
   * 
   * @see javax.jms.Session#createProducer
   * @see javax.jms.CompletionListener
   * 
   * @since JMS 2.0
   */
  void send(Message message, CompletionListener completionListener)
      throws JMSException;

  /**
   * Sends a message, specifying delivery mode, priority and time to live,
   * performing part of the work involved in sending the message in a separate
   * thread and notifying the specified CompletionListener when the
   * operation has completed. JMS refers to this as an "asynchronous send".
   * 
   * @param message
   *          the message to send
   * @param deliveryMode
   *          the delivery mode to use
   * @param priority
   *          the priority for this message
   * @param timeToLive
   *          the message's lifetime (in milliseconds)
   * @param completionListener
   *          a {@code CompletionListener} to be notified when the send has
   *          completed
   * 
   * @exception JMSException
   *              if an internal error occurs
   * @exception MessageFormatException
   *              if an invalid message is specified.
   * @exception InvalidDestinationException
   *              if a client uses this method with a {@code MessageProducer}
   *              with an invalid destination.
   * @exception java.lang.IllegalArgumentException
   *              if the specified {@code CompletionListener} is null
   * @exception java.lang.UnsupportedOperationException
   *              if a client uses this method with a {@code MessageProducer}
   *              that did not specify a destination at creation time.
   * 
   * @see javax.jms.Session#createProducer
   * @see javax.jms.CompletionListener
   * 
   * @since JMS 2.0
   */

  void send(Message message, int deliveryMode, int priority, long timeToLive,
      CompletionListener completionListener) throws JMSException;

  /**
   * Sends a message to a destination for an unidentified message producer,
   * using the {@code MessageProducer}'s default delivery mode, priority, and
   * time to live, performing part of the work involved in sending the message
   * in a separate thread and notifying the specified
   * CompletionListener when the operation has completed. JMS refers to
   * this as an "asynchronous send".
   * 
   * @param destination
   *          the destination to send this message to
   * @param message
   *          the message to send
   * @param completionListener
   *          a {@code CompletionListener} to be notified when the send has
   *          completed
   * 
   * @exception JMSException
   *              if an internal error occurs
   * @exception MessageFormatException
   *              if an invalid message is specified.
   * @exception InvalidDestinationException
   *              if a client uses this method with an invalid destination
   * @exception java.lang.IllegalArgumentException
   *              if the specified {@code CompletionListener} is null
   * @exception java.lang.UnsupportedOperationException
   *              if a client uses this method with a {@code MessageProducer}
   *              that specified a destination at creation time.
   * 
   * @see javax.jms.Session#createProducer
   * @see javax.jms.CompletionListener
   * 
   * @since JMS 2.0
   */

  void send(Destination destination, Message message,
      CompletionListener completionListener) throws JMSException;

  /**
   * Sends a message to a destination for an unidentified message producer,
   * specifying delivery mode, priority and time to live, performing part of the
   * work involved in sending the message in a separate thread and notifying the
   * specified CompletionListener when the operation has completed. JMS
   * refers to this as an "asynchronous send".
   * 
   * @param destination
   *          the destination to send this message to
   * @param message
   *          the message to send
   * @param deliveryMode
   *          the delivery mode to use
   * @param priority
   *          the priority for this message
   * @param timeToLive
   *          the message's lifetime (in milliseconds)
   * @param completionListener
   *          a {@code CompletionListener} to be notified when the send has
   *          completed
   * 
   * @exception JMSException
   *              if an internal error occurs
   * @exception MessageFormatException
   *              if an invalid message is specified.
   * @exception InvalidDestinationException
   *              if a client uses this method with an invalid destination.
   * @exception java.lang.IllegalArgumentException
   *              if the specified {@code CompletionListener} is null
   * @exception java.lang.UnsupportedOperationException
   *              if a client uses this method with a {@code MessageProducer}
   *              that specified a destination at creation time.
   * 
   * @see javax.jms.Session#createProducer
   * @see javax.jms.CompletionListener
   * 
   * @since JMS 2.0
   */

  void send(Destination destination, Message message, int deliveryMode,
      int priority, long timeToLive, CompletionListener completionListener)
      throws JMSException;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy