Top Description Methods
javax.jms

public Interface JMSProducer

Imports
java.io.Serializable, java.util.Map, .Set

A 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.

Since
JMS 2.0
Version
JMS 2.0

Method Summary

Modifier and TypeMethod and Description
public JMSProducer

Returns:

this JMSProducer
clearProperties
()

Clears any message properties set on this JMSProducer

public CompletionListener

Returns:

the CompletionListener or null
getAsync
()

If subsequent calls to send on this JMSProducer object have been configured to be asynchronous then this method returns the CompletionListener that has previously been configured.

public boolean

Returns:

the property value, converted to a boolean
getBooleanProperty
(String
the name of the property
name
)

Returns the message property with the specified name that has been set on this JMSProducer, converted to a boolean.

public byte

Returns:

the property value, converted to a byte
getByteProperty
(String
the name of the property
name
)

Returns the message property with the specified name that has been set on this JMSProducer, converted to a String.

public long

Returns:

the delivery delay in milliseconds.
getDeliveryDelay
()

Gets the minimum length of time in milliseconds that must elapse after a message is sent before the JMS provider may deliver the message to a consumer.

public int

Returns:

the message delivery mode
getDeliveryMode
()

Returns the delivery mode of messages that are sent using this JMSProducer

public boolean

Returns:

an indication of whether message IDs are disabled
getDisableMessageID
()

Gets an indication of whether message IDs are disabled.

public boolean

Returns:

an indication of whether message timestamps are disabled
getDisableMessageTimestamp
()

Gets an indication of whether message timestamps are disabled.

public double

Returns:

the property value, converted to a double
getDoubleProperty
(String
the name of the property
name
)

Returns the message property with the specified name that has been set on this JMSProducer, converted to a double.

public float

Returns:

the property value, converted to a float
getFloatProperty
(String
the name of the property
name
)

Returns the message property with the specified name that has been set on this JMSProducer, converted to a float.

public int

Returns:

the property value, converted to a int
getIntProperty
(String
the name of the property
name
)

Returns the message property with the specified name that has been set on this JMSProducer, converted to a int.

public String

Returns:

the correlation ID of a message as a String
getJMSCorrelationID
()

Returns the JMSCorrelationID header value that has been set on this JMSProducer, as a String.

public byte[]

Returns:

the correlation ID as an array of bytes
getJMSCorrelationIDAsBytes
()

Returns the JMSCorrelationID header value that has been set on this JMSProducer, as an array of bytes.

public Destination

Returns:

Destination the JMSReplyTo header value
getJMSReplyTo
()

Returns the JMSReplyTo header value that has been set on this JMSProducer.

public String

Returns:

the message type
getJMSType
()

Returns the JMSType header value that has been set on this JMSProducer.

public long

Returns:

the property value, converted to a long
getLongProperty
(String
the name of the property
name
)

Returns the message property with the specified name that has been set on this JMSProducer, converted to a long.

public Object

Returns:

the Java object property value with the specified name, in objectified format (for example, if the property was set as an int, an Integer is returned); if there is no property by this name, a null value is returned
getObjectProperty
(String
the name of the property
name
)

Returns the message property with the specified name that has been set on this JMSProducer, converted to objectified format.

public int

Returns:

the message priority
getPriority
()

Return the priority of messages that are sent using this JMSProducer

public Set<String>

Returns:

a Set containing the names of all the message properties that have been set on this JMSProducer
getPropertyNames
()

Returns an unmodifiable Set view of the names of all the message properties that have been set on this JMSProducer.

public short

Returns:

the property value, converted to a short
getShortProperty
(String
the name of the property
name
)

Returns the message property with the specified name that has been set on this JMSProducer, converted to a short.

public String

Returns:

the property value, converted to a boolean; if there is no property by this name, a null value is returned
getStringProperty
(String
the name of the property
name
)

Returns the message property with the specified name that has been set on this JMSProducer, converted to a String.

public long

Returns:

the message time to live in milliseconds; a value of zero means that a message never expires.
getTimeToLive
()

Returns the time to live of messages that are sent using this JMSProducer.

public boolean

Returns:

true whether the property exists
propertyExists
(String
the name of the property
name
)

Indicates whether a message property with the specified name has been set on this JMSProducer

public JMSProducer

Returns:

this JMSProducer
send
(Destination
the 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 JMSProducer.

public JMSProducer

Returns:

this JMSProducer
send
(Destination
the destination to send this message to
destination
,
String
the body of the TextMessage that will be sent. If a null value is specified then a TextMessage with no body will be sent.
body
)

Send a TextMessage with the specified body to the specified destination, using any send options, message properties and message headers that have been defined on this JMSProducer.

public JMSProducer

Returns:

this JMSProducer
send
(Destination
the destination to send this message to
destination
,
Map<String, Object>
the body of the MapMessage that will be sent. If a null value is specified then a MapMessage with no map entries will be sent.
body
)

Send a MapMessage with the specified body to the specified destination, using any send options, message properties and message headers that have been defined on this JMSProducer.

public JMSProducer

Returns:

this JMSProducer
send
(Destination
the destination to send this message to
destination
,
byte[]
the body of the BytesMessage that will be sent. If a null value is specified then a BytesMessage with no body will be sent.
body
)

Send a BytesMessage with the specified body to the specified destination, using any send options, message properties and message headers that have been defined on this JMSProducer.

public JMSProducer

Returns:

this JMSProducer
send
(Destination
the 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 ObjectMessage with no body will be sent.
body
)

Send an ObjectMessage with the specified body to the specified destination, using any send options, message properties and message headers that have been defined on this JMSProducer.

public JMSProducer

Returns:

this JMSProducer
setAsync
(CompletionListener
If asynchronous send behaviour is required, this should be set to a CompletionListener to be notified when the send has completed. If synchronous send behaviour is required, this should be set to null.
completionListener
)

Specifies whether subsequent calls to send on this JMSProducer object should be synchronous or asynchronous.

public JMSProducer

Returns:

this JMSProducer
setDeliveryDelay
(long
the delivery delay in milliseconds.
deliveryDelay
)

Sets the minimum length of time in milliseconds that must elapse after a message is sent before the JMS provider may deliver the message to a consumer.

public JMSProducer

Returns:

this JMSProducer
setDeliveryMode
(int
the message delivery mode to be used; legal values are DeliveryMode.NON_PERSISTENT and DeliveryMode.PERSISTENT
deliveryMode
)

Specifies the delivery mode of messages that are sent using this JMSProducer

Delivery mode is set to PERSISTENT by default.

public JMSProducer

Returns:

this JMSProducer
setDisableMessageID
(boolean
indicates whether message IDs may be disabled
value
)

Specifies whether message IDs may be disabled for messages that are sent using this JMSProducer

Since message IDs take some effort to create and increase a message's size, some JMS 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:

this JMSProducer
setDisableMessageTimestamp
(boolean
indicates whether message timestamps may be disabled
value
)

Specifies whether message timestamps may be disabled for messages that are sent using this JMSProducer.

public JMSProducer

Returns:

this JMSProducer
setJMSCorrelationID
(String
the message ID of a message being referred to
correlationID
)

Specifies that messages sent using this JMSProducer will have their JMSCorrelationID header value set to the specified correlation ID, where correlation ID is specified as a String.

public JMSProducer

Returns:

this JMSProducer
setJMSCorrelationIDAsBytes
(byte[]
the correlation ID value as an array of bytes
correlationID
)

Specifies that messages sent using this JMSProducer will have their JMSCorrelationID header value set to the specified correlation ID, where correlation ID is specified as an array of bytes.

public JMSProducer

Returns:

this JMSProducer
setJMSReplyTo
(Destination
Destination to which to send a response to this message
replyTo
)

Specifies that messages sent using this JMSProducer will have their JMSReplyTo header value set to the specified Destination object.

public JMSProducer

Returns:

this JMSProducer
setJMSType
(String
the message type
type
)

Specifies that messages sent using this JMSProducer will have their JMSType header value set to the specified message type.

public JMSProducer

Returns:

this JMSProducer
setPriority
(int
the message priority to be used; must be a value between 0 and 9
priority
)

Specifies the priority of messages that are sent using this JMSProducer

The JMS API defines ten levels of priority value, with 0 as the lowest priority and 9 as the highest.

public JMSProducer

Returns:

this JMSProducer
setProperty
(String
the name of the property
name
,
boolean
the boolean value to set
value
)

Specifies that messages sent using this JMSProducer will have the specified property set to the specified boolean value.

public JMSProducer

Returns:

this JMSProducer
setProperty
(String
the name of the property
name
,
byte
the byte value to set
value
)

Specifies that messages sent using this JMSProducer will have the specified property set to the specified byte value.

public JMSProducer

Returns:

this JMSProducer
setProperty
(String
the name of the property
name
,
short
the short property value to set
value
)

Specifies that messages sent using this JMSProducer will have the specified property set to the specified short value.

public JMSProducer

Returns:

this JMSProducer
setProperty
(String
the name of the property
name
,
int
the int property value to set
value
)

Specifies that messages sent using this JMSProducer will have the specified property set to the specified int value.

public JMSProducer

Returns:

this JMSProducer
setProperty
(String
the name of the property
name
,
long
the long property value to set
value
)

Specifies that messages sent using this JMSProducer will have the specified property set to the specified long value.

public JMSProducer

Returns:

this JMSProducer
setProperty
(String
the name of the property
name
,
float
the float property value to set
value
)

Specifies that messages sent using this JMSProducer will have the specified property set to the specified float value.

public JMSProducer

Returns:

this JMSProducer
setProperty
(String
the name of the property
name
,
double
the double property value to set
value
)

Specifies that messages sent using this JMSProducer will have the specified property set to the specified double value.

public JMSProducer

Returns:

this JMSProducer
setProperty
(String
the name of the property
name
,
String
the String property value to set
value
)

Specifies that messages sent using this JMSProducer will have the specified property set to the specified String value.

public JMSProducer

Returns:

this JMSProducer
setProperty
(String
the name of the property
name
,
Object
the Java object property value to set
value
)

Specifies that messages sent using this JMSProducer will have the specified property set to the specified Java object value.

public JMSProducer

Returns:

this JMSProducer
setTimeToLive
(long
the 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 JMSProducer.