public final class ActiveMQJMSProducer extends Object implements JMSProducer
setDisableMessageID(boolean)
and
setDisableMessageTimestamp(boolean)
calls their equivalent at the
MessageProducer
. IF the user is using the producer in async mode, this may lead to races.
We allow/tolerate this because these are just optional optimizations.Modifier and Type | Method and Description |
---|---|
JMSProducer |
clearProperties()
Clears any message properties set on this
JMSProducer |
CompletionListener |
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. |
boolean |
getBooleanProperty(String name)
Returns the message property with the specified name that has been set on
this
JMSProducer , converted to a boolean . |
byte |
getByteProperty(String name)
Returns the message property with the specified name that has been set on
this
JMSProducer , converted to a String . |
long |
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.
|
int |
getDeliveryMode()
Returns the delivery mode of messages that are sent using this
JMSProducer |
boolean |
getDisableMessageID()
Gets an indication of whether message IDs are disabled.
|
boolean |
getDisableMessageTimestamp()
Gets an indication of whether message timestamps are disabled.
|
double |
getDoubleProperty(String name)
Returns the message property with the specified name that has been set on
this
JMSProducer , converted to a double . |
float |
getFloatProperty(String name)
Returns the message property with the specified name that has been set on
this
JMSProducer , converted to a float . |
int |
getIntProperty(String name)
Returns the message property with the specified name that has been set on
this
JMSProducer , converted to a int . |
String |
getJMSCorrelationID()
Returns the
JMSCorrelationID header value that has been set
on this JMSProducer , as a String . |
byte[] |
getJMSCorrelationIDAsBytes()
Returns the
JMSCorrelationID header value that has been set
on this JMSProducer , as an array of bytes. |
Destination |
getJMSReplyTo()
Returns the
JMSReplyTo header value that has been set on
this JMSProducer . |
String |
getJMSType()
Returns the
JMSType header value that has been set on this
JMSProducer . |
long |
getLongProperty(String name)
Returns the message property with the specified name that has been set on
this
JMSProducer , converted to a long . |
Object |
getObjectProperty(String name)
Returns the message property with the specified name that has been set on
this
JMSProducer , converted to objectified format. |
int |
getPriority()
Return the priority of messages that are sent using this
JMSProducer |
Set<String> |
getPropertyNames()
Returns an unmodifiable
Set view of the names of all the message
properties that have been set on this JMSProducer. |
short |
getShortProperty(String name)
Returns the message property with the specified name that has been set on
this
JMSProducer , converted to a short . |
String |
getStringProperty(String name)
Returns the message property with the specified name that has been set on
this
JMSProducer , converted to a String . |
long |
getTimeToLive()
Returns the time to live of messages that are sent using this
JMSProducer . |
boolean |
propertyExists(String name)
Indicates whether a message property with the specified name has been set
on this
JMSProducer |
JMSProducer |
send(Destination destination,
byte[] 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 . |
JMSProducer |
send(Destination destination,
Map<String,Object> 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 . |
JMSProducer |
send(Destination destination,
Message message)
Sends a message to the specified destination, using any send options,
message properties and message headers that have been defined on this
JMSProducer . |
JMSProducer |
send(Destination destination,
Serializable 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 . |
JMSProducer |
send(Destination destination,
String 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 . |
JMSProducer |
setAsync(CompletionListener completionListener)
Specifies whether subsequent calls to
send on this
JMSProducer object should be synchronous or asynchronous. |
JMSProducer |
setDeliveryDelay(long 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.
|
JMSProducer |
setDeliveryMode(int deliveryMode)
Specifies the delivery mode of messages that are sent using this
JMSProducer |
JMSProducer |
setDisableMessageID(boolean value)
Specifies whether message IDs may be disabled for messages that are sent
using this
JMSProducer |
JMSProducer |
setDisableMessageTimestamp(boolean value)
Specifies whether message timestamps may be disabled for messages that
are sent using this
JMSProducer . |
JMSProducer |
setJMSCorrelationID(String 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 . |
JMSProducer |
setJMSCorrelationIDAsBytes(byte[] 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. |
JMSProducer |
setJMSReplyTo(Destination replyTo)
Specifies that messages sent using this
JMSProducer will
have their JMSReplyTo header value set to the specified
Destination object. |
JMSProducer |
setJMSType(String type)
Specifies that messages sent using this
JMSProducer will
have their JMSType header value set to the specified message
type. |
JMSProducer |
setPriority(int priority)
Specifies the priority of messages that are sent using this
JMSProducer |
JMSProducer |
setProperty(String name,
boolean value)
Specifies that messages sent using this
JMSProducer will
have the specified property set to the specified boolean
value. |
JMSProducer |
setProperty(String name,
byte value)
Specifies that messages sent using this
JMSProducer will
have the specified property set to the specified byte value. |
JMSProducer |
setProperty(String name,
double value)
Specifies that messages sent using this
JMSProducer will
have the specified property set to the specified double
value. |
JMSProducer |
setProperty(String name,
float value)
Specifies that messages sent using this
JMSProducer will
have the specified property set to the specified float
value. |
JMSProducer |
setProperty(String name,
int value)
Specifies that messages sent using this
JMSProducer will
have the specified property set to the specified int value. |
JMSProducer |
setProperty(String name,
long value)
Specifies that messages sent using this
JMSProducer will
have the specified property set to the specified long value. |
JMSProducer |
setProperty(String name,
Object value)
Specifies that messages sent using this
JMSProducer will
have the specified property set to the specified Java object value. |
JMSProducer |
setProperty(String name,
short value)
Specifies that messages sent using this
JMSProducer will
have the specified property set to the specified short
value. |
JMSProducer |
setProperty(String name,
String value)
Specifies that messages sent using this
JMSProducer will
have the specified property set to the specified String
value. |
JMSProducer |
setTimeToLive(long timeToLive)
Specifies the time to live of messages that are sent using this
JMSProducer . |
public JMSProducer send(Destination destination, Message message)
JMSProducer
JMSProducer
.send
in interface JMSProducer
destination
- the destination to send this message tomessage
- the message to sendJMSProducer
public JMSProducer send(Destination destination, String body)
JMSProducer
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
.send
in interface JMSProducer
destination
- the destination to send this message tobody
- the body of the TextMessage
that will be sent.
If a null value is specified then a TextMessage
with no body will be sent.JMSProducer
public JMSProducer send(Destination destination, Map<String,Object> body)
JMSProducer
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
.send
in interface JMSProducer
destination
- the destination to send this message tobody
- 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.JMSProducer
public JMSProducer send(Destination destination, byte[] body)
JMSProducer
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
.send
in interface JMSProducer
destination
- the destination to send this message tobody
- the body of the BytesMessage
that will be
sent.
If a null value is specified then a BytesMessage
with no body will be sent.JMSProducer
public JMSProducer send(Destination destination, Serializable body)
JMSProducer
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
.send
in interface JMSProducer
destination
- the destination to send this message tobody
- the body of the ObjectMessage that will be sent.
If a null value is specified then an ObjectMessage
with no body will be sent.JMSProducer
public JMSProducer setDisableMessageID(boolean value)
JMSProducer
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. By
calling this method, a JMS application enables this potential
optimisation for all messages sent using this JMSProducer
.
If the JMS provider accepts this hint, these messages must have the
message ID set to null; if the provider ignores the hint, the message ID
must be set to its normal unique value.
Message IDs are enabled by default.
setDisableMessageID
in interface JMSProducer
value
- indicates whether message IDs may be disabledJMSProducer
JMSProducer.getDisableMessageID()
public boolean getDisableMessageID()
JMSProducer
getDisableMessageID
in interface JMSProducer
JMSProducer.setDisableMessageID(boolean)
public JMSProducer setDisableMessageTimestamp(boolean value)
JMSProducer
JMSProducer
. JMSProducer
. If the JMS provider accepts this
hint, these messages must have the timestamp set to zero; if the provider
ignores the hint, the timestamp must be set to its normal value.
Message timestamps are enabled by default.
setDisableMessageTimestamp
in interface JMSProducer
value
- indicates whether message timestamps may be disabledJMSProducer
JMSProducer.getDisableMessageTimestamp()
public boolean getDisableMessageTimestamp()
JMSProducer
getDisableMessageTimestamp
in interface JMSProducer
JMSProducer.setDisableMessageTimestamp(boolean)
public JMSProducer setDeliveryMode(int deliveryMode)
JMSProducer
JMSProducer
Delivery mode is set to PERSISTENT
by default.
setDeliveryMode
in interface JMSProducer
deliveryMode
- the message delivery mode to be used; legal values are
DeliveryMode.NON_PERSISTENT
and
DeliveryMode.PERSISTENT
JMSProducer
JMSProducer.getDeliveryMode()
,
DeliveryMode.NON_PERSISTENT
,
DeliveryMode.PERSISTENT
,
Message.DEFAULT_DELIVERY_MODE
public int getDeliveryMode()
JMSProducer
JMSProducer
getDeliveryMode
in interface JMSProducer
JMSProducer.setDeliveryMode(int)
public JMSProducer setPriority(int priority)
JMSProducer
JMSProducer
The JMS API defines ten levels of priority value, with 0 as the lowest priority and 9 as the highest. Clients should consider priorities 0-4 as gradations of normal priority and priorities 5-9 as gradations of expedited priority. Priority is set to 4 by default.
setPriority
in interface JMSProducer
priority
- the message priority to be used; must be a value between 0 and
9JMSProducer
JMSProducer.getPriority()
,
Message.DEFAULT_PRIORITY
public int getPriority()
JMSProducer
JMSProducer
getPriority
in interface JMSProducer
JMSProducer.setPriority(int)
public JMSProducer setTimeToLive(long timeToLive)
JMSProducer
JMSProducer
. This is used to determine the expiration time
of a message.
The expiration time of a message is the sum of the message's time to live and the time it is sent. For transacted sends, this is the time the client sends the message, not the time the transaction is committed.
Clients should not receive messages that have expired; however, JMS does not guarantee that this will not happen.
A JMS provider should do its best to accurately expire messages; however, JMS does not define the accuracy provided. It is not acceptable to simply ignore time-to-live.
Time to live is set to zero by default, which means a message never expires.
setTimeToLive
in interface JMSProducer
timeToLive
- the message time to live to be used, in milliseconds; a value
of zero means that a message never expires.JMSProducer
JMSProducer.getTimeToLive()
,
Message.DEFAULT_TIME_TO_LIVE
public long getTimeToLive()
JMSProducer
JMSProducer
.getTimeToLive
in interface JMSProducer
JMSProducer.setTimeToLive(long)
public JMSProducer setDeliveryDelay(long deliveryDelay)
JMSProducer
For transacted sends, this time starts when the client sends the message, not when the transaction is committed.
deliveryDelay is set to zero by default.
setDeliveryDelay
in interface JMSProducer
deliveryDelay
- the delivery delay in milliseconds.JMSProducer
JMSProducer.getDeliveryDelay()
,
Message.DEFAULT_DELIVERY_DELAY
public long getDeliveryDelay()
JMSProducer
getDeliveryDelay
in interface JMSProducer
JMSProducer.setDeliveryDelay(long)
public JMSProducer setAsync(CompletionListener completionListener)
JMSProducer
send
on this
JMSProducer
object should be synchronous or asynchronous. If
the specified CompletionListener
is not null then subsequent
calls to send
will be asynchronous. If the specified
CompletionListener
is null then subsequent calls to
send
will be synchronous. Calls to send
are
synchronous by default.
If a call to send
is asynchronous then part of the work
involved in sending the message will be performed in a separate thread
and the specified CompletionListener will be notified when the
operation has completed.
When the message has been successfully sent the JMS provider invokes the callback method onCompletion on the CompletionListener object. Only when that callback has been invoked can the application be sure that the message has been successfully sent with the same degree of confidence as if the send had been synchronous. An application which requires this degree of confidence must therefore wait for the callback to be invoked before continuing.
The following information is intended to give an indication of how an asynchronous send would typically be implemented.
In some JMS providers, a normal synchronous send involves sending the message to a remote JMS server and then waiting for an acknowledgement to be received before returning. It is expected that such a provider would implement an asynchronous send by sending the message to the remote JMS server and then returning without waiting for an acknowledgement. When the acknowledgement is received, the JMS provider would notify the application by invoking the onCompletion method on the application-specified CompletionListener object. If for some reason the acknowledgement is not received the JMS provider would notify the application by invoking the CompletionListener's onException method.
In those cases where the JMS specification permits a lower level of reliability, a normal synchronous send might not wait for an acknowledgement. In that case it is expected that an asynchronous send would be similar to a synchronous send: the JMS provider would send the message to the remote JMS server and then return without waiting for an acknowledgement. However the JMS provider would still notify the application that the send had completed by invoking the onCompletion method on the application-specified CompletionListener object.
It is up to the JMS provider to decide exactly what is performed in the calling thread and what, if anything, is performed asynchronously, so long as it satisfies the requirements given below:
Quality of service: After the send operation has completed successfully, which means that the message has been successfully sent with the same degree of confidence as if a normal synchronous send had been performed, the JMS provider must invoke the CompletionListener's onCompletion method. The CompletionListener must not be invoked earlier than this.
Exceptions: If an exception is encountered during the call to the send method then an appropriate exception should be thrown in the thread that is calling the send method. In this case the JMS provider must not invoke the CompletionListener's onCompletion or onException method. If an exception is encountered which cannot be thrown in the thread that is calling the send method then the JMS provider must call the CompletionListener's onException method. In both cases if an exception occurs it is undefined whether or not the message was successfully sent.
Message order: If the same JMSContext is used to send multiple messages then JMS message ordering requirements must be satisfied. This applies even if a combination of synchronous and asynchronous sends has been performed. The application is not required to wait for an asynchronous send to complete before sending the next message.
Close, commit or rollback: If the close method is called
on the JMSContext then the JMS provider must block until any
incomplete send operations have been completed and all
CompletionListener
callbacks have returned before closing
the object and returning. If the session is transacted (uses a local
transaction) then when the JMSContext's commit or
rollback method is called the JMS provider must block until any
incomplete send operations have been completed and all
CompletionListener
callbacks have returned before performing
the commit or rollback. Incomplete sends should be allowed to complete
normally unless an error occurs.
A CompletionListener callback method must not call close, commit or rollback on its own JMSContext. Doing so will cause the close, commit or rollback to throw an IllegalStateRuntimeException.
Restrictions on usage in Java EE This method must not be used in a
Java EE EJB or web container. Doing so may cause a JMSRuntimeException
to be thrown though this is not guaranteed.
Message headers JMS defines a number of message header fields and message properties which must be set by the "JMS provider on send". If the send is asynchronous these fields and properties may be accessed on the sending client only after the CompletionListener has been invoked. If the CompletionListener's onException method is called then the state of these message header fields and properties is undefined.
Restrictions on threading: Applications that perform an asynchronous send must confirm to the threading restrictions defined in JMS. This means that the session may be used by only one thread at a time.
Setting a CompletionListener does not cause the session to be dedicated to the thread of control which calls the CompletionListener. The application thread may therefore continue to use the session after performing an asynchronous send. However the CompletionListener's callback methods must not use the session if an application thread might be using the session at the same time.
Use of the CompletionListener by the JMS provider: A
session will only invoke one CompletionListener callback method
at a time. For a given JMSContext, callbacks (both
onCompletion
and onException
) will be performed
in the same order as the corresponding calls to the send method.
A JMS provider must not invoke the CompletionListener from the
thread that is calling the send method.
Restrictions on the use of the Message object: Applications which perform an asynchronous send must take account of the restriction that a Message object is designed to be accessed by one logical thread of control at a time and does not support concurrent use.
After the send method has returned, the application must not attempt to read the headers, properties or body of the Message object until the CompletionListener's onCompletion or onException method has been called. This is because the JMS provider may be modifying the Message object in another thread during this time. The JMS provider may throw an JMSException if the application attempts to access or modify the Message object after the send method has returned and before the CompletionListener has been invoked. If the JMS provider does not throw an exception then the behaviour is undefined.
setAsync
in interface JMSProducer
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
.JMSProducer
JMSProducer.getAsync()
,
CompletionListener
public CompletionListener getAsync()
JMSProducer
send
on this
JMSProducer
object have been configured to be asynchronous
then this method returns the CompletionListener
that has previously been configured.
If subsequent calls to send
have been configured to be synchronous
then this method returns null
.getAsync
in interface JMSProducer
CompletionListener
or null
JMSProducer.setAsync(javax.jms.CompletionListener)
public JMSProducer setProperty(String name, boolean value)
JMSProducer
JMSProducer
will
have the specified property set to the specified boolean
value.
This will replace any property of the same name that is already set on the message being sent.
setProperty
in interface JMSProducer
name
- the name of the propertyvalue
- the boolean
value to setJMSProducer
JMSProducer.getBooleanProperty(java.lang.String)
public JMSProducer setProperty(String name, byte value)
JMSProducer
JMSProducer
will
have the specified property set to the specified byte
value.
This will replace any property of the same name that is already set on the message being sent.
setProperty
in interface JMSProducer
name
- the name of the propertyvalue
- the byte
value to setJMSProducer
JMSProducer.getByteProperty(java.lang.String)
public JMSProducer setProperty(String name, short value)
JMSProducer
JMSProducer
will
have the specified property set to the specified short
value.
This will replace any property of the same name that is already set on the message being sent.
setProperty
in interface JMSProducer
name
- the name of the propertyvalue
- the short
property value to setJMSProducer
JMSProducer.getShortProperty(java.lang.String)
public JMSProducer setProperty(String name, int value)
JMSProducer
JMSProducer
will
have the specified property set to the specified int
value.
This will replace any property of the same name that is already set on the message being sent.
setProperty
in interface JMSProducer
name
- the name of the propertyvalue
- the int
property value to setJMSProducer
JMSProducer.getIntProperty(java.lang.String)
public JMSProducer setProperty(String name, long value)
JMSProducer
JMSProducer
will
have the specified property set to the specified long
value.
This will replace any property of the same name that is already set on the message being sent.
setProperty
in interface JMSProducer
name
- the name of the propertyvalue
- the long
property value to setJMSProducer
JMSProducer.getLongProperty(java.lang.String)
public JMSProducer setProperty(String name, float value)
JMSProducer
JMSProducer
will
have the specified property set to the specified float
value.
This will replace any property of the same name that is already set on the message being sent.
setProperty
in interface JMSProducer
name
- the name of the propertyvalue
- the float
property value to setJMSProducer
JMSProducer.getFloatProperty(java.lang.String)
public JMSProducer setProperty(String name, double value)
JMSProducer
JMSProducer
will
have the specified property set to the specified double
value.
This will replace any property of the same name that is already set on the message being sent.
setProperty
in interface JMSProducer
name
- the name of the propertyvalue
- the double
property value to setJMSProducer
JMSProducer.getDoubleProperty(java.lang.String)
public JMSProducer setProperty(String name, String value)
JMSProducer
JMSProducer
will
have the specified property set to the specified String
value.
This will replace any property of the same name that is already set on the message being sent.
setProperty
in interface JMSProducer
name
- the name of the propertyvalue
- the String
property value to setJMSProducer
JMSProducer.getStringProperty(java.lang.String)
public JMSProducer setProperty(String name, Object value)
JMSProducer
JMSProducer
will
have the specified property set to the specified Java object value.
Note that this method works only for the objectified primitive object
types (Integer
, Double
, Long
...)
and String
objects.
This will replace any property of the same name that is already set on the message being sent.
setProperty
in interface JMSProducer
name
- the name of the propertyvalue
- the Java object property value to setJMSProducer
JMSProducer.getObjectProperty(java.lang.String)
public JMSProducer clearProperties()
JMSProducer
JMSProducer
clearProperties
in interface JMSProducer
JMSProducer
public boolean propertyExists(String name)
JMSProducer
JMSProducer
propertyExists
in interface JMSProducer
name
- the name of the propertypublic boolean getBooleanProperty(String name)
JMSProducer
JMSProducer
, converted to a boolean
.getBooleanProperty
in interface JMSProducer
name
- the name of the propertyboolean
JMSProducer.setProperty(java.lang.String,boolean)
public byte getByteProperty(String name)
JMSProducer
JMSProducer
, converted to a String
.getByteProperty
in interface JMSProducer
name
- the name of the propertybyte
JMSProducer.setProperty(java.lang.String,byte)
public short getShortProperty(String name)
JMSProducer
JMSProducer
, converted to a short
.getShortProperty
in interface JMSProducer
name
- the name of the propertyshort
JMSProducer.setProperty(java.lang.String,short)
public int getIntProperty(String name)
JMSProducer
JMSProducer
, converted to a int
.getIntProperty
in interface JMSProducer
name
- the name of the propertyint
JMSProducer.setProperty(java.lang.String,int)
public long getLongProperty(String name)
JMSProducer
JMSProducer
, converted to a long
.getLongProperty
in interface JMSProducer
name
- the name of the propertylong
JMSProducer.setProperty(java.lang.String,long)
public float getFloatProperty(String name)
JMSProducer
JMSProducer
, converted to a float
.getFloatProperty
in interface JMSProducer
name
- the name of the propertyfloat
JMSProducer.setProperty(java.lang.String,float)
public double getDoubleProperty(String name)
JMSProducer
JMSProducer
, converted to a double
.getDoubleProperty
in interface JMSProducer
name
- the name of the propertydouble
JMSProducer.setProperty(java.lang.String,double)
public String getStringProperty(String name)
JMSProducer
JMSProducer
, converted to a String
.getStringProperty
in interface JMSProducer
name
- the name of the propertyboolean
; if there
is no property by this name, a null value is returnedJMSProducer.setProperty(java.lang.String,String)
public Object getObjectProperty(String name)
JMSProducer
JMSProducer
, converted to objectified format.
This method can be used to return, in objectified format, an object that
has been stored as a property in the message with the equivalent
setObjectProperty
method call, or its equivalent primitive
set<I>type</I>Property
method.
getObjectProperty
in interface JMSProducer
name
- the name of the propertyint
, an Integer
is returned); if there
is no property by this name, a null value is returnedJMSProducer.setProperty(java.lang.String,java.lang.Object)
public Set<String> getPropertyNames()
JMSProducer
Set
view of the names of all the message
properties that have been set on this JMSProducer.
Note that JMS standard header fields are not considered properties and are not returned in this Set.
The set is backed by the JMSProducer
, so changes to the map are
reflected in the set. However the set may not be modified. Attempts to
modify the returned collection, whether directly or via its iterator,
will result in an java.lang.UnsupportedOperationException
. Its behaviour matches
that defined in the java.util.Collections
method
unmodifiableSet
.
getPropertyNames
in interface JMSProducer
Set
containing the names of all the message properties
that have been set on this JMSProducer
Collections.unmodifiableSet(java.util.Set<? extends T>)
public JMSProducer setJMSCorrelationIDAsBytes(byte[] correlationID)
JMSProducer
JMSProducer
will
have their JMSCorrelationID
header value set to the
specified correlation ID, where correlation ID is specified as an array
of bytes.
This will override any JMSCorrelationID
header value that is
already set on the message being sent.
The array is copied before the method returns, so future modifications to
the array will not alter the value in this JMSProducer
.
If a provider supports the native concept of correlation ID, a JMS client
may need to assign specific JMSCorrelationID
values to match
those expected by native messaging clients. JMS providers without native
correlation ID values are not required to support this method and its
corresponding get method; their implementation may throw a
java.lang.UnsupportedOperationException
.
The use of a byte[]
value for JMSCorrelationID
is non-portable.
setJMSCorrelationIDAsBytes
in interface JMSProducer
correlationID
- the correlation ID value as an array of bytesJMSProducer
JMSProducer.setJMSCorrelationID(String)
,
JMSProducer.getJMSCorrelationID()
,
JMSProducer.getJMSCorrelationIDAsBytes()
public byte[] getJMSCorrelationIDAsBytes()
JMSProducer
JMSCorrelationID
header value that has been set
on this JMSProducer
, as an array of bytes.
The use of a byte[]
value for JMSCorrelationID
is non-portable.
getJMSCorrelationIDAsBytes
in interface JMSProducer
JMSProducer.setJMSCorrelationID(String)
,
JMSProducer.getJMSCorrelationID()
,
JMSProducer.setJMSCorrelationIDAsBytes(byte[])
public JMSProducer setJMSCorrelationID(String correlationID)
JMSProducer
JMSProducer
will
have their JMSCorrelationID
header value set to the
specified correlation ID, where correlation ID is specified as a
String
.
This will override any JMSCorrelationID
header value that is
already set on the message being sent.
A client can use the JMSCorrelationID
header field to link
one message with another. A typical use is to link a response message
with its request message.
JMSCorrelationID
can hold one of the following:
String
byte[]
value
Since each message sent by a JMS provider is assigned a message ID value,
it is convenient to link messages via message ID. All message ID values
must start with the 'ID:'
prefix.
In some cases, an application (made up of several clients) needs to use
an application-specific value for linking messages. For instance, an
application may use JMSCorrelationID
to hold a value
referencing some external information. Application-specified values must
not start with the 'ID:'
prefix; this is reserved for
provider-generated message ID values.
If a provider supports the native concept of correlation ID, a JMS client
may need to assign specific JMSCorrelationID
values to match
those expected by clients that do not use the JMS API. A
byte[]
value is used for this purpose. JMS providers without
native correlation ID values are not required to support
byte[]
values. The use of a byte[]
value for
JMSCorrelationID
is non-portable.
setJMSCorrelationID
in interface JMSProducer
correlationID
- the message ID of a message being referred toJMSProducer
JMSProducer.getJMSCorrelationID()
,
JMSProducer.getJMSCorrelationIDAsBytes()
,
JMSProducer.setJMSCorrelationIDAsBytes(byte[])
public String getJMSCorrelationID()
JMSProducer
JMSCorrelationID
header value that has been set
on this JMSProducer
, as a String
.
This method is used to return correlation ID values that are either
provider-specific message IDs or application-specific String
values.
getJMSCorrelationID
in interface JMSProducer
String
JMSProducer.setJMSCorrelationID(String)
,
JMSProducer.getJMSCorrelationIDAsBytes()
,
JMSProducer.setJMSCorrelationIDAsBytes(byte[])
public JMSProducer setJMSType(String type)
JMSProducer
JMSProducer
will
have their JMSType
header value set to the specified message
type.
This will override any JMSType
header value that is already
set on the message being sent.
Some JMS providers use a message repository that contains the definitions
of messages sent by applications. The JMSType
header field
may reference a message's definition in the provider's repository.
The JMS API does not define a standard message definition repository, nor does it define a naming policy for the definitions it contains.
Some messaging systems require that a message type definition for each
application message be created and that each message specify its type. In
order to work with such JMS providers, JMS clients should assign a value
to JMSType
, whether the application makes use of it or not.
This ensures that the field is properly set for those providers that
require it.
To ensure portability, JMS clients should use symbolic values for
JMSType
that can be configured at installation time to the
values defined in the current provider's message repository. If string
literals are used, they may not be valid type names for some JMS
providers.
setJMSType
in interface JMSProducer
type
- the message typeJMSProducer
JMSProducer.getJMSType()
public String getJMSType()
JMSProducer
JMSType
header value that has been set on this
JMSProducer
.getJMSType
in interface JMSProducer
JMSProducer.setJMSType(String)
public JMSProducer setJMSReplyTo(Destination replyTo)
JMSProducer
JMSProducer
will
have their JMSReplyTo
header value set to the specified
Destination
object.
This will override any JMSReplyTo
header value that is
already set on the message being sent.
The JMSReplyTo
header field contains the destination where a
reply to the current message should be sent. If it is null, no reply is
expected. The destination may be either a Queue
object or a
Topic
object.
Messages sent with a null JMSReplyTo
value may be a
notification of some event, or they may just be some data the sender
thinks is of interest.
Messages with a JMSReplyTo
value typically expect a
response. A response is optional; it is up to the client to decide. These
messages are called requests. A message sent in response to a request is
called a reply.
In some cases a client may wish to match a request it sent earlier with a
reply it has just received. The client can use the
JMSCorrelationID
header field for this purpose.
setJMSReplyTo
in interface JMSProducer
replyTo
- Destination
to which to send a response to this
messageJMSProducer
JMSProducer.getJMSReplyTo()
public Destination getJMSReplyTo()
JMSProducer
JMSReplyTo
header value that has been set on
this JMSProducer
.
getJMSReplyTo
in interface JMSProducer
Destination
the JMSReplyTo
header valueJMSProducer.setJMSReplyTo(Destination)
Copyright © 2017 JBoss by Red Hat. All rights reserved.