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 void
close()
Closes the message producer.long
getDeliveryDelay()
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, javax.jms.CompletionListener completionListener)
void
send(javax.jms.Destination destination, javax.jms.Message message, int deliveryMode, int priority, long timeToLive, javax.jms.CompletionListener completionListener)
void
send(javax.jms.Message message)
Sends a message.void
send(javax.jms.Message message, javax.jms.CompletionListener completionListener)
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
send(javax.jms.Message message, int deliveryMode, int priority, long timeToLive, javax.jms.CompletionListener completionListener)
void
setDeliveryDelay(long deliveryDelay)
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 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.JMSException
Closes 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejavax.jms.MessageProducer
- Throws:
javax.jms.JMSException
- if the operation does not succeed
-
getDeliveryMode
public int getDeliveryMode() throws javax.jms.JMSException
Gets the producer's default delivery mode.- Specified by:
getDeliveryMode
in 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.JMSException
Gets the destination associated with the message producer.- Specified by:
getDestination
in interfacejavax.jms.MessageProducer
- Returns:
- the message destination.
- Throws:
javax.jms.JMSException
- if the operation fails
-
getDisableMessageID
public boolean getDisableMessageID() throws javax.jms.JMSException
Indicates whether message IDs are disabled.- Specified by:
getDisableMessageID
in 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.JMSException
Indicates whether message timestamps are disabled.- Specified by:
getDisableMessageTimestamp
in 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.JMSException
Gets the producer's default priority.- Specified by:
getPriority
in 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.JMSException
Gets the default length of time that a produced message will be retained by the message system.- Specified by:
getTimeToLive
in 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.JMSException
Sends a message. Uses the message producer's default delivery mode, default priority, and default time to live.- Specified by:
send
in 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.JMSException
Sends a message specifying a delivery mode, a priority, and the lifetime of the message.- Specified by:
send
in 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.JMSException
Sets the producer's default delivery mode.- Specified by:
setDeliveryMode
in 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.JMSException
Sets whether message IDs are disabled.Note: This method is ignored in the IBM MQ Java Message Service extensions implementation.
- Specified by:
setDisableMessageID
in 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.JMSException
Sets whether message timestamps are disabled. They are enabled by default.- Specified by:
setDisableMessageTimestamp
in 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.JMSException
Sets the producer's default priority.- Specified by:
setPriority
in 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.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 real-time connection to a broker.
- Specified by:
setTimeToLive
in 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:
getDeliveryDelay
in 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:
send
in interfacejavax.jms.MessageProducer
- Throws:
javax.jms.JMSException
javax.jms.MessageFormatException
javax.jms.InvalidDestinationException
java.lang.IllegalArgumentException
java.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:
send
in interfacejavax.jms.MessageProducer
- Throws:
javax.jms.JMSException
javax.jms.MessageFormatException
javax.jms.InvalidDestinationException
java.lang.IllegalArgumentException
java.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:
send
in interfacejavax.jms.MessageProducer
- Throws:
javax.jms.JMSException
javax.jms.MessageFormatException
javax.jms.InvalidDestinationException
java.lang.IllegalArgumentException
java.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:
send
in interfacejavax.jms.MessageProducer
- Throws:
javax.jms.JMSException
javax.jms.MessageFormatException
javax.jms.InvalidDestinationException
java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
-
setDeliveryDelay
public void setDeliveryDelay(long deliveryDelay) throws javax.jms.JMSException
- Specified by:
setDeliveryDelay
in interfacejavax.jms.MessageProducer
- Throws:
javax.jms.JMSException
- See Also:
MessageProducer.setDeliveryDelay(long)
-
-