com.ibm.mq.jms
Class MQMessageProducer
- java.lang.Object
-
- com.ibm.mq.jms.MQRoot
-
- com.ibm.mq.jms.MQMessageProducer
-
- All Implemented Interfaces:
- JmsMessageProducer, JmsPropertyContext, JmsReadablePropertyContext, java.io.Serializable, java.lang.AutoCloseable, java.util.Map<java.lang.String,java.lang.Object>, javax.jms.MessageProducer
- Direct Known Subclasses:
- MQQueueSender, MQTopicPublisher
public class MQMessageProducer extends MQRoot implements javax.jms.MessageProducer, JmsMessageProducer
A client uses an MQMessageProducer to send messages to a destination.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()Closes the message producer.longgetDeliveryDelay()intgetDeliveryMode()Gets the producer's default delivery mode.javax.jms.DestinationgetDestination()Gets the destination associated with the message producer.booleangetDisableMessageID()Indicates whether message IDs are disabled.booleangetDisableMessageTimestamp()Indicates whether message timestamps are disabled.intgetPriority()Gets the producer's default priority.longgetTimeToLive()Gets the default length of time that a produced message will be retained by the message system.voidsend(javax.jms.Destination destination, javax.jms.Message message, javax.jms.CompletionListener completionListener)voidsend(javax.jms.Destination destination, javax.jms.Message message, int deliveryMode, int priority, long timeToLive, javax.jms.CompletionListener completionListener)voidsend(javax.jms.Message message)Sends a message.voidsend(javax.jms.Message message, javax.jms.CompletionListener completionListener)voidsend(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.voidsend(javax.jms.Message message, int deliveryMode, int priority, long timeToLive, javax.jms.CompletionListener completionListener)voidsetDeliveryDelay(long deliveryDelay)voidsetDeliveryMode(int deliveryMode)Sets the producer's default delivery mode.voidsetDisableMessageID(boolean value)Sets whether message IDs are disabled.voidsetDisableMessageTimestamp(boolean value)Sets whether message timestamps are disabled.voidsetPriority(int priority)Sets the producer's default priority.voidsetTimeToLive(long timeToLive)Sets the default length of time that the message system retains a produced message.-
Methods inherited from class com.ibm.mq.jms.MQRoot
clear, containsKey, containsValue, entrySet, equals, get, getBooleanProperty, getByteProperty, getBytesProperty, getCharProperty, getDoubleProperty, getFloatProperty, getIntProperty, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, hashCode, isEmpty, keySet, propertyExists, put, putAll, remove, setBatchProperties, setBooleanProperty, setByteProperty, setBytesProperty, setCharProperty, setDoubleProperty, setFloatProperty, setIntProperty, setLongProperty, setObjectProperty, setShortProperty, setStringProperty, size, values
-
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ibm.msg.client.jms.JmsPropertyContext
setBatchProperties, setBooleanProperty, setByteProperty, setBytesProperty, setCharProperty, setDoubleProperty, setFloatProperty, setIntProperty, setLongProperty, setObjectProperty, setShortProperty, setStringProperty
-
Methods inherited from interface com.ibm.msg.client.jms.JmsReadablePropertyContext
getBooleanProperty, getByteProperty, getBytesProperty, getCharProperty, getDoubleProperty, getFloatProperty, getIntProperty, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, propertyExists
-
-
-
-
Method Detail
-
close
public void close() throws javax.jms.JMSExceptionCloses the message producer. Because a provider can allocate some resources outside the JVM on behalf of message producers, 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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejavax.jms.MessageProducer- Throws:
javax.jms.JMSException- if the operation does not succeed
-
getDeliveryMode
public int getDeliveryMode() throws javax.jms.JMSExceptionGets the producer's default delivery mode.- Specified by:
getDeliveryModein interfacejavax.jms.MessageProducer- Returns:
- the message delivery mode for this message producer.
- Throws:
javax.jms.JMSException- if the operation fails.- See Also:
setDeliveryMode(int)
-
getDestination
public javax.jms.Destination getDestination() throws javax.jms.JMSExceptionGets the destination associated with the message producer.- Specified by:
getDestinationin interfacejavax.jms.MessageProducer- Returns:
- the message destination.
- Throws:
javax.jms.JMSException- if the operation fails
-
getDisableMessageID
public boolean getDisableMessageID() throws javax.jms.JMSExceptionIndicates whether message IDs are disabled.- Specified by:
getDisableMessageIDin interfacejavax.jms.MessageProducer- Returns:
- true if message IDs are disabled.
- Throws:
javax.jms.JMSException- if the operation fails
-
getDisableMessageTimestamp
public boolean getDisableMessageTimestamp() throws javax.jms.JMSExceptionIndicates whether message timestamps are disabled.- Specified by:
getDisableMessageTimestampin interfacejavax.jms.MessageProducer- Returns:
- true indicates that timestamps are disabled.
- Throws:
javax.jms.JMSException- if the operation fails
-
getPriority
public int getPriority() throws javax.jms.JMSExceptionGets the producer's default priority.- Specified by:
getPriorityin interfacejavax.jms.MessageProducer- Returns:
- the message priority for this message producer.
- Throws:
javax.jms.JMSException- if the operation fails- See Also:
setPriority(int)
-
getTimeToLive
public long getTimeToLive() throws javax.jms.JMSExceptionGets the default length of time that a produced message will be retained by the message system.- Specified by:
getTimeToLivein interfacejavax.jms.MessageProducer- Returns:
- the length of time from its dispatch that a message is retained by default (milliseconds).
- Throws:
javax.jms.JMSException- if the operation fails- See Also:
setTimeToLive(long)
-
send
public void send(javax.jms.Message message) throws javax.jms.JMSExceptionSends a message. Uses the message producer's default delivery mode, default priority, and default time to live.- Specified by:
sendin interfacejavax.jms.MessageProducer- Parameters:
message- the message to be sent.- Throws:
javax.jms.JMSException- if the operation fails
-
send
public void send(javax.jms.Message message, int deliveryMode, int priority, long timeToLive) throws javax.jms.JMSExceptionSends a message specifying a delivery mode, a priority, and the lifetime of the message.- Specified by:
sendin interfacejavax.jms.MessageProducer- Parameters:
message- the message to send.deliveryMode- the delivery mode to use.priority- the priority for the messagetimeToLive- the lifetime of the message in milliseconds.- Throws:
javax.jms.JMSException- if the operation fails
-
setDeliveryMode
public void setDeliveryMode(int deliveryMode) throws javax.jms.JMSExceptionSets the producer's default delivery mode.- Specified by:
setDeliveryModein interfacejavax.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- if the operation fails- See Also:
getDeliveryMode(),Message.DEFAULT_DELIVERY_MODE
-
setDisableMessageID
public void setDisableMessageID(boolean value) throws javax.jms.JMSExceptionSets whether message IDs are disabled.Note: This method is ignored in the IBM MQ Java Message Service extensions implementation.
- Specified by:
setDisableMessageIDin interfacejavax.jms.MessageProducer- Parameters:
value- true if message IDs are disabled. Message IDs are enabled by default.- Throws:
javax.jms.JMSException- if the operation fails
-
setDisableMessageTimestamp
public void setDisableMessageTimestamp(boolean value) throws javax.jms.JMSExceptionSets whether message timestamps are disabled. They are enabled by default.- Specified by:
setDisableMessageTimestampin interfacejavax.jms.MessageProducer- Parameters:
value- true indicates that timestamps are disabled.- Throws:
javax.jms.JMSException- if the operation fails
-
setPriority
public void setPriority(int priority) throws javax.jms.JMSExceptionSets the producer's default priority.- Specified by:
setPriorityin interfacejavax.jms.MessageProducer- Parameters:
priority- the message priority for this message producer. Possible values are:WMQConstants.WMQ_PRI_QDEF- An integer between 0 and 9, inclusive.
- Throws:
javax.jms.JMSException- if the operation fails- See Also:
getPriority(),Message.DEFAULT_PRIORITY
-
setTimeToLive
public void setTimeToLive(long timeToLive) throws javax.jms.JMSExceptionSets 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 real-time connection to a broker.
- Specified by:
setTimeToLivein interfacejavax.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- if the operation fails- See Also:
getTimeToLive(),Message.DEFAULT_TIME_TO_LIVE
-
getDeliveryDelay
public long getDeliveryDelay() throws javax.jms.JMSException- Specified by:
getDeliveryDelayin interfacejavax.jms.MessageProducer- Throws:
javax.jms.JMSException- See Also:
MessageProducer.getDeliveryDelay()
-
send
public void send(javax.jms.Message message, javax.jms.CompletionListener completionListener) throws javax.jms.JMSException, javax.jms.MessageFormatException, javax.jms.InvalidDestinationException, java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException- Specified by:
sendin interfacejavax.jms.MessageProducer- Throws:
javax.jms.JMSExceptionjavax.jms.MessageFormatExceptionjavax.jms.InvalidDestinationExceptionjava.lang.IllegalArgumentExceptionjava.lang.UnsupportedOperationException
-
send
public void send(javax.jms.Destination destination, javax.jms.Message message, javax.jms.CompletionListener completionListener) throws javax.jms.JMSException, javax.jms.MessageFormatException, javax.jms.InvalidDestinationException, java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException- Specified by:
sendin interfacejavax.jms.MessageProducer- Throws:
javax.jms.JMSExceptionjavax.jms.MessageFormatExceptionjavax.jms.InvalidDestinationExceptionjava.lang.IllegalArgumentExceptionjava.lang.UnsupportedOperationException
-
send
public void send(javax.jms.Message message, int deliveryMode, int priority, long timeToLive, javax.jms.CompletionListener completionListener) throws javax.jms.JMSException, javax.jms.MessageFormatException, javax.jms.InvalidDestinationException, java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException- Specified by:
sendin interfacejavax.jms.MessageProducer- Throws:
javax.jms.JMSExceptionjavax.jms.MessageFormatExceptionjavax.jms.InvalidDestinationExceptionjava.lang.IllegalArgumentExceptionjava.lang.UnsupportedOperationException
-
send
public void send(javax.jms.Destination destination, javax.jms.Message message, int deliveryMode, int priority, long timeToLive, javax.jms.CompletionListener completionListener) throws javax.jms.JMSException, javax.jms.MessageFormatException, javax.jms.InvalidDestinationException, java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException- Specified by:
sendin interfacejavax.jms.MessageProducer- Throws:
javax.jms.JMSExceptionjavax.jms.MessageFormatExceptionjavax.jms.InvalidDestinationExceptionjava.lang.IllegalArgumentExceptionjava.lang.UnsupportedOperationException
-
setDeliveryDelay
public void setDeliveryDelay(long deliveryDelay) throws javax.jms.JMSException- Specified by:
setDeliveryDelayin interfacejavax.jms.MessageProducer- Throws:
javax.jms.JMSException- See Also:
MessageProducer.setDeliveryDelay(long)
-
-