JMSProducer is a simple object used to send messages on behalf of a JMSContext. An instance of
JMSProducer is created by calling the createProducer method on a JMSContext. It provides
various send methods to send a message to a specified destination. It also provides methods to allow message
send options, message properties and message headers to be specified prior to sending a message or set of messages.
Message send options may be specified using one or more of the following methods: setDeliveryMode,
setPriority, setTimeToLive, setDeliveryDelay, setDisableMessageTimestamp,
setDisableMessageID and setAsync.
Message properties may be may be specified using one or more of nine setProperty methods. Any message
properties set using these methods will override any message properties that have been set directly on the message.
Message headers may be specified using one or more of the following methods: setJMSCorrelationID,
setJMSCorrelationIDAsBytes, setJMSType or setJMSReplyTo. Any message headers set using these
methods will override any message headers that have been set directly on the message.
All the above methods return the JMSProducer to allow method calls to be chained together, allowing a fluid
programming style. For example:
context.createProducer().setDeliveryMode(DeliveryMode.NON_PERSISTENT).setTimeToLive(1000).send(destination, message);
Instances of JMSProducer are intended to be lightweight objects which can be created freely and which do not
consume significant resources. This interface therefore does not provide a close method.
| Modifier and Type | Method and Description |
|---|---|
| public JMSProducer | |
| public CompletionListener | Returns: theCompletionListener or nullIf subsequent calls to |
| public boolean | Returns: the property value, converted to abooleanthe name of the property name)Returns the message property with the specified name that has been set on this |
| public byte | Returns: the property value, converted to abytethe name of the property name)Returns the message property with the specified name that has been set on this |
| public long | Returns: the delivery delay in milliseconds.Gets the minimum length of time in milliseconds that must elapse after a message is sent before the Jakarta Messaging provider may deliver the message to a consumer. |
| public int | Returns: the message delivery modeReturns the delivery mode of messages that are sent using this |
| public boolean | Returns: an indication of whether message IDs are disabledGets an indication of whether message IDs are disabled. |
| public boolean | Returns: an indication of whether message timestamps are disabledGets an indication of whether message timestamps are disabled. |
| public double | Returns: the property value, converted to adoublethe name of the property name)Returns the message property with the specified name that has been set on this |
| public float | Returns: the property value, converted to afloatthe name of the property name)Returns the message property with the specified name that has been set on this |
| public int | Returns: the property value, converted to aintthe name of the property name)Returns the message property with the specified name that has been set on this |
| public String | Returns: the correlation ID of a message as aStringReturns the |
| public byte[] | Returns: the correlation ID as an array of bytesReturns the |
| public Destination | Returns: Destination the JMSReplyTo header valueReturns the |
| public String | Returns: the message typeReturns the |
| public long | Returns: the property value, converted to alongthe name of the property name)Returns the message property with the specified name that has been set on this |
| public Object | Returns: the Java object property value with the specified name, in objectified format (for example, if the property was set as anint, an Integer is returned); if there is no property by this name, a null value is
returnedthe name of the property name)Returns the message property with the specified name that has been set on this |
| public int | Returns: the message priorityReturn the priority of messages that are sent using this |
| public Set | Returns: aSet containing the names of all the message properties that have been set on this
JMSProducerReturns an unmodifiable |
| public short | Returns: the property value, converted to ashortthe name of the property name)Returns the message property with the specified name that has been set on this |
| public String | Returns: the property value, converted to aboolean; if there is no property by this name, a null value is
returnedthe name of the property name)Returns the message property with the specified name that has been set on this |
| public long | Returns: the message time to live in milliseconds; a value of zero means that a message never expires.Returns the time to live of messages that are sent using this |
| public boolean | Returns: true whether the property existsthe name of the property name)Indicates whether a message property with the specified name has been set on this |
| public JMSProducer | Returns: thisJMSProducerthe destination to send this message to destination, Message the message to send message)Sends a message to the specified destination, using any send options, message properties and message headers that
have been defined on this |
| public JMSProducer | Returns: thisJMSProducerthe destination to send this message to destination, String the body of the body)TextMessage that will be sent. If a null value is specified then a
TextMessage with no body will be sent.Send a |
| public JMSProducer | Returns: thisJMSProducerthe destination to send this message to destination, Map<String, Object> the body of the body)MapMessage that will be sent. If a null value is specified then a
MapMessage with no map entries will be sent.Send a |
| public JMSProducer | Returns: thisJMSProducerthe destination to send this message to destination, byte[] the body of the body)BytesMessage that will be sent. If a null value is specified then a
BytesMessage with no body will be sent.Send a |
| public JMSProducer | Returns: thisJMSProducerthe destination to send this message to destination, Serializable the body of the ObjectMessage that will be sent. If a null value is specified then an
body)ObjectMessage with no body will be sent.Send an |
| public JMSProducer | Returns: thisJMSProducerIf asynchronous send behaviour is required, this should be set to a
completionListener)CompletionListener to be notified when the send has completed. If synchronous send behaviour is required,
this should be set to null.Specifies whether subsequent calls to |
| public JMSProducer | Returns: thisJMSProducerthe delivery delay in milliseconds. deliveryDelay)Sets the minimum length of time in milliseconds that must elapse after a message is sent before the Jakarta Messaging provider may deliver the message to a consumer. |
| public JMSProducer | Returns: thisJMSProducerthe message delivery mode to be used; legal values are deliveryMode)DeliveryMode.NON_PERSISTENT and
DeliveryMode.PERSISTENTSpecifies the delivery mode of messages that are sent using this
Delivery mode is set to |
| public JMSProducer | Returns: thisJMSProducerindicates whether message IDs may be disabled value)Specifies whether message IDs may be disabled for messages that are sent using this Since message IDs take some effort to create and increase a message's size, some Jakarta Messaging providers may be able to optimise message overhead if they are given a hint that the message ID is not used by an application. |
| public JMSProducer | Returns: thisJMSProducerindicates whether message timestamps may be disabled value)Specifies whether message timestamps may be disabled for messages that are sent using this |
| public JMSProducer | Returns: thisJMSProducerthe message ID of a message being referred to correlationID)Specifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe correlation ID value as an array of bytes correlationID)Specifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerDestination to which to send a response to this messageSpecifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe message type type)Specifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe message priority to be used; must be a value between 0 and 9 priority)Specifies the priority of messages that are sent using this The Jakarta Messaging API defines ten levels of priority value, with 0 as the lowest priority and 9 as the highest. |
| public JMSProducer | Returns: thisJMSProducerthe name of the property name, boolean the value)boolean value to setSpecifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe name of the property name, byte the value)byte value to setSpecifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe name of the property name, short the value)short property value to setSpecifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe name of the property name, int the value)int property value to setSpecifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe name of the property name, long the value)long property value to setSpecifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe name of the property name, float the value)float property value to setSpecifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe name of the property name, double the value)double property value to setSpecifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe name of the property name, String the value)String property value to setSpecifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe name of the property name, Object the Java object property value to set value)Specifies that messages sent using this |
| public JMSProducer | Returns: thisJMSProducerthe message time to live to be used, in milliseconds; a value of zero means that a message never
expires. timeToLive)Specifies the time to live of messages that are sent using this |