com.ibm.mq.jms
Class MQMessageProducer

java.lang.Object
  |
  +--com.ibm.mq.jms.MQMessageProducer
All Implemented Interfaces:
javax.jms.MessageProducer
Direct Known Subclasses:
MQQueueSender, MQTopicPublisher

public class MQMessageProducer
extends java.lang.Object
implements javax.jms.MessageProducer

A client uses an MQMessageProducer to send messages to a destination.


Method Summary
 void close()
          Closes the message producer.
 int getDeliveryMode()
          Gets the producer's default delivery mode.
 javax.jms.Destination getDestination()
          Gets the destination associated with the message producer.
 boolean getDisableMessageID()
          Indicates whether message IDs are disabled.
 boolean getDisableMessageTimestamp()
          Indicates whether message timestamps are disabled.
 int getPriority()
          Gets the producer's default priority.
 long getTimeToLive()
          Gets the default length of time that a produced message will be retained by the message system.
 void send(javax.jms.Destination destination, javax.jms.Message message)
          Sends a message to a destination if you are using a message producer for which no destination was specified when the message producer was created.
 void send(javax.jms.Destination destination, javax.jms.Message message, int deliveryMode, int priority, long timeToLive)
          Sends a message to a destination if you are using a message producer for which no destination was specified when the message producer was created.
 void send(javax.jms.Message message)
          Sends a message.
 void send(javax.jms.Message message, int deliveryMode, int priority, long timeToLive)
          Sends a message specifying a delivery mode, a priority, and the lifetime of the message.
 void setDeliveryMode(int deliveryMode)
          Sets the producer's default delivery mode.
 void setDisableMessageID(boolean value)
          Sets whether message IDs are disabled.
 void setDisableMessageTimestamp(boolean value)
          Sets whether message timestamps are disabled.
 void setPriority(int priority)
          Sets the producer's default priority.
 void setTimeToLive(long timeToLive)
          Sets the default length of time that the message system retains a produced message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public void close()
           throws javax.jms.JMSException
Closes the message producer. Because a provider can allocate some resources outside the JVM on behalf of a MessageProducer, clients must close them when they are not needed. You cannot rely on garbage collection to reclaim these resources because this might not occur soon enough.

Specified by:
close in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException - with reason MQJMS_EXCEPTION_MQ_Q_CLOSE_FAILED

setDisableMessageID

public void setDisableMessageID(boolean value)
                         throws javax.jms.JMSException
Sets whether message IDs are disabled.

Service implementation.

Specified by:
setDisableMessageID in interface javax.jms.MessageProducer
Parameters:
value - true if message IDs are disabled. Message IDs are enabled by default.
Throws:
javax.jms.JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED

getDisableMessageID

public boolean getDisableMessageID()
                            throws javax.jms.JMSException
Indicates whether message IDs are disabled.

Specified by:
getDisableMessageID in interface javax.jms.MessageProducer
Returns:
true if message IDs are disabled.
Throws:
javax.jms.JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED

setDisableMessageTimestamp

public void setDisableMessageTimestamp(boolean value)
                                throws javax.jms.JMSException
Sets whether message timestamps are disabled. They are enabled by default.

Specified by:
setDisableMessageTimestamp in interface javax.jms.MessageProducer
Parameters:
value - true indicates that timestamps are disabled.
Throws:
javax.jms.JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED

getDisableMessageTimestamp

public boolean getDisableMessageTimestamp()
                                   throws javax.jms.JMSException
Indicates whether message timestamps are disabled.

Specified by:
getDisableMessageTimestamp in interface javax.jms.MessageProducer
Returns:
true indicates that timestamps are disabled.
Throws:
javax.jms.JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED

setDeliveryMode

public void setDeliveryMode(int deliveryMode)
                     throws javax.jms.JMSException
Sets the producer's default delivery mode.

Specified by:
setDeliveryMode in interface javax.jms.MessageProducer
Parameters:
deliveryMode - the message delivery mode for this message producer. Possible values are:
  • DeliveryMode.NON_PERSISTENT
  • DeliveryMode.PERSISTENT, the default
Throws:
javax.jms.JMSException - with one of the following reasons:
See Also:
getDeliveryMode(), Message.DEFAULT_DELIVERY_MODE

getDeliveryMode

public int getDeliveryMode()
                    throws javax.jms.JMSException
Gets the producer's default delivery mode.

Specified by:
getDeliveryMode in interface javax.jms.MessageProducer
Returns:
the message delivery mode for this message producer.
Throws:
javax.jms.JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED
See Also:
setDeliveryMode(int)

setPriority

public void setPriority(int priority)
                 throws javax.jms.JMSException
Sets the producer's default priority.

Specified by:
setPriority in interface javax.jms.MessageProducer
Parameters:
priority - the message priority for this message producer. Values can be between 0 and 9, inclusive. The default is 4.
Throws:
javax.jms.JMSException - with one of the following reasons:
See Also:
getPriority(), Message.DEFAULT_PRIORITY

getPriority

public int getPriority()
                throws javax.jms.JMSException
Gets the producer's default priority.

Specified by:
getPriority in interface javax.jms.MessageProducer
Returns:
the message priority for this message producer.
Throws:
javax.jms.JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED
See Also:
setPriority(int)

setTimeToLive

public void setTimeToLive(long timeToLive)
                   throws javax.jms.JMSException
Sets the default length of time that the message system retains a produced message.

Note that this method throws a JMSException if set to other than 0 when you make a direct connection to a broker.

Specified by:
setTimeToLive in interface javax.jms.MessageProducer
Parameters:
timeToLive - the length of time from its dispatch that a message is retained by default (milliseconds). The default is zero which means unlimited time.
Throws:
javax.jms.JMSException - with one of the following reasons:
See Also:
getTimeToLive(), Message.DEFAULT_TIME_TO_LIVE

getTimeToLive

public long getTimeToLive()
                   throws javax.jms.JMSException
Gets the default length of time that a produced message will be retained by the message system.

Specified by:
getTimeToLive in interface javax.jms.MessageProducer
Returns:
the length of time from its dispatch that a message is retained by default (milliseconds).
Throws:
javax.jms.JMSException - with reason MQJMS_MESSAGEPRODUCER_CLOSED
See Also:
setTimeToLive(long)

send

public void send(javax.jms.Message message,
                 int deliveryMode,
                 int priority,
                 long timeToLive)
          throws javax.jms.JMSException
Sends a message specifying a delivery mode, a priority, and the lifetime of the message.

Specified by:
send in interface javax.jms.MessageProducer
Parameters:
message - the message to send.
deliveryMode - the delivery mode to use.
priority - the priority for the message
timeToLive - the lifetime of the message in milliseconds.
Throws:
javax.jms.JMSException - with one of the following reasons:
Since:
JMS 1.1
See Also:
MQSession.createProducer(javax.jms.Destination)

send

public void send(javax.jms.Message message)
          throws javax.jms.JMSException
Sends a message. Uses the message producer's default delivery mode, default priority, and default time to live.

Specified by:
send in interface javax.jms.MessageProducer
Parameters:
message - the message to be sent.
Throws:
javax.jms.JMSException - with one of the following reasons:
java.lang.UnsupportedOperationException - if a client uses this method with a message producer for which no destination was specified when it was created.
Since:
JMS 1.1

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message,
                 int deliveryMode,
                 int priority,
                 long timeToLive)
          throws javax.jms.JMSException
Sends a message to a destination if you are using a message producer for which no destination was specified when the message producer was created. The method specifies a delivery mode, a priority, and message lifetime. Typically, you specify a destination when you create a message producer but, if do not, you must specify a destination every time you send a message.

Specified by:
send in interface javax.jms.MessageProducer
Parameters:
destination - the destination to which to send the message.
message - the message to send.
deliveryMode - the delivery mode to use
priority - the priority for the message
timeToLive - the lifetime of the message in milliseconds
Throws:
javax.jms.JMSException - with one of the following reasons:
Since:
JMS 1.1
See Also:
MQSession.createProducer(javax.jms.Destination)

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message)
          throws javax.jms.JMSException
Sends a message to a destination if you are using a message producer for which no destination was specified when the message producer was created. The method uses the message producer's default delivery mode, default priority, and default message lifetime. Typically, you specify a destination when you create a message producer but, if you do not, you must specify a destination every time you send a message.

Specified by:
send in interface javax.jms.MessageProducer
Parameters:
destination - the message destination.
message - the message to send.
Throws:
javax.jms.JMSException - with one of the following reasons:
Since:
JMS 1.1
See Also:
MQSession.createProducer(javax.jms.Destination)

getDestination

public javax.jms.Destination getDestination()
                                     throws javax.jms.JMSException
Gets the destination associated with the message producer.

Specified by:
getDestination in interface javax.jms.MessageProducer
Returns:
the message destination.
Throws:
javax.jms.JMSException - with reasons MQJMS_E_INTERNAL_ERROR
Since:
JMS 1.1

(c) Copyright IBM Corp. 2005. All Rights Reserved.