Creating Message Producers
JMS applications use a MessageProducer
object to send messages to destinations. To create a MessageProducer
, call session.createProducer(Destination destination)
.
You can also configure default properties for a producer instance through the following methods:
MessageProducer.setDeliveryMode(int deliveryMode)
Sets the producer’s default delivery mode (Persistent or Non-Persistent). If the delivery mode is not specified, the default delivery mode specified in the Connection Factory is used.
By default, Direct Transport is used to deliver Non-Persistent messages from producers to the event broker. (The message transport mode is set through the Connection Factory; for more information on message transport modes, refer to Message Transport Modes.)
MessageProducer.setDisableMessageID(boolean value)
Sets whether message IDs are disabled. Note that disabling message IDs can improve performance.
MessageProducer.setDisableMessageTimestamp(boolean value)
Sets whether message timestamps are disabled. Note that disabling message timestamps can improve performance.
-
MessageProducer.setPriority (int defaultPriority)
Sets the producer's default priority value, with 0 being the lowest priority and 9 the highest.
When an endpoint is configured to enforce message priority, it increases the chance that duplicate messages will be delivered to a consuming client after it recovers from a connection failure (refer to Message Priority).
MessageProducer.setTimeToLive(long timeToLive)
Sets TTL value (in milliseconds) for sent messages. A value of 0 means that the messages never expire.