public class SQSMessage
extends java.lang.Object
Not all message headers are supported at this time:
JMSMessageID is always assigned as SQS provided message id.JMSRedelivered is set to true if SQS delivers the message
more than once. This not necessarily mean that the user received message more
than once, but rather SQS attempted to deliver it more than once. Due to
prefetching used in SQSMessageConsumerPrefetch, this can be set to
true although user never received the message. This is set based on SQS
ApproximateReceiveCount attributeJMSDestinationJMSXDeliveryCount reserved property is supported and set based on the approximate receive count observed on the SQS side.
| Modifier and Type | Class and Description |
|---|---|
static class |
SQSMessage.JMSMessagePropertyValue
This class is used fulfill object value, corresponding SQS message
attribute type and message attribute string value.
|
static class |
SQSMessage.TypeConversionSupport
Copied from org.apache.activemq.util.TypeConversionSupport to provide the
same property support provided by activemq without creating a dependency
on activemq.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BYTE_MESSAGE_TYPE |
static java.lang.String |
JMS_SQS_MESSAGE_TYPE |
static java.lang.String |
JMS_SQS_REPLY_TO_QUEUE_NAME |
static java.lang.String |
JMS_SQS_REPLY_TO_QUEUE_URL |
static java.lang.String |
OBJECT_MESSAGE_TYPE |
static java.lang.String |
TEXT_MESSAGE_TYPE |
| Modifier and Type | Method and Description |
|---|---|
void |
acknowledge()
Acknowledges message(s).
|
protected void |
checkBodyWritePermissions() |
protected void |
checkPropertyWritePermissions() |
void |
clearBody()
Clears out the message body.
|
void |
clearProperties()
Clears a message's properties and set the write permissions for
properties.
|
protected static JMSException |
convertExceptionToJMSException(java.lang.Exception e) |
protected static MessageFormatException |
convertExceptionToMessageFormatException(java.lang.Exception e) |
boolean |
getBooleanProperty(java.lang.String name)
Returns the value of the
boolean property with the specified
name. |
byte |
getByteProperty(java.lang.String name)
Returns the value of the
byte property with the specified
name. |
double |
getDoubleProperty(java.lang.String name)
Returns the value of the
double property with the specified
name. |
float |
getFloatProperty(java.lang.String name)
Returns the value of the
float property with the specified
name. |
int |
getIntProperty(java.lang.String name)
Returns the value of the
int property with the specified
name. |
java.lang.String |
getJMSCorrelationID() |
byte[] |
getJMSCorrelationIDAsBytes() |
int |
getJMSDeliveryMode() |
Destination |
getJMSDestination()
Gets the Destination object for this message.
|
long |
getJMSExpiration() |
java.lang.String |
getJMSMessageID()
Gets the message ID.
|
SQSMessage.JMSMessagePropertyValue |
getJMSMessagePropertyValue(java.lang.String name)
Returns the property value with message attribute to object property
conversions took place.
|
int |
getJMSPriority() |
boolean |
getJMSRedelivered() |
Destination |
getJMSReplyTo() |
long |
getJMSTimestamp() |
java.lang.String |
getJMSType() |
long |
getLongProperty(java.lang.String name)
Returns the value of the
long property with the specified
name. |
java.lang.Object |
getObjectProperty(java.lang.String name)
Returns the value of the Java object property with the specified name.
|
java.util.Enumeration<java.lang.String> |
getPropertyNames()
Returns an
Enumeration of all the property names. |
java.lang.String |
getQueueUrl()
Get queueUrl the message came from.
|
java.lang.String |
getReceiptHandle()
Get SQS Message receiptHandle.
|
short |
getShortProperty(java.lang.String name)
Returns the value of the
short property with the specified
name. |
java.lang.String |
getSQSMessageDeduplicationId()
Get SQS Message Deduplication Id (applicable for FIFO queues, available also as JMS property 'JMS_SQS_DeduplicationId')
|
java.lang.String |
getSQSMessageGroupId()
Get SQS Message Group Id (applicable for FIFO queues, available also as JMS property 'JMSXGroupId')
|
java.lang.String |
getSQSMessageId()
Get SQS Message Id.
|
java.lang.String |
getSQSMessageSequenceNumber()
Get SQS Message Sequence Number (applicable for FIFO queues, available also as JMS property 'JMS_SQS_SequenceNumber')
|
java.lang.String |
getStringProperty(java.lang.String name)
Returns the value of the
String property with the specified
name. |
boolean |
propertyExists(java.lang.String name)
Indicates whether a property value exists for the given property name.
|
protected void |
setBodyWritePermissions(boolean enable) |
void |
setBooleanProperty(java.lang.String name,
boolean value)
Sets a
boolean property value with the specified name into
the message. |
void |
setByteProperty(java.lang.String name,
byte value)
Sets a
byte property value with the specified name into
the message. |
void |
setDoubleProperty(java.lang.String name,
double value)
Sets a
double property value with the specified name into
the message. |
void |
setFloatProperty(java.lang.String name,
float value)
Sets a
float property value with the specified name into
the message. |
void |
setIntProperty(java.lang.String name,
int value)
Sets a
int property value with the specified name into
the message. |
void |
setJMSCorrelationID(java.lang.String correlationID) |
void |
setJMSCorrelationIDAsBytes(byte[] correlationID) |
void |
setJMSDeliveryMode(int deliveryMode) |
void |
setJMSDestination(Destination destination)
Sets the Destination object for this message.
|
void |
setJMSExpiration(long expiration) |
void |
setJMSMessageID(java.lang.String id)
Sets the message ID.
|
void |
setJMSPriority(int priority) |
void |
setJMSRedelivered(boolean redelivered) |
void |
setJMSReplyTo(Destination replyTo) |
void |
setJMSTimestamp(long timestamp) |
void |
setJMSType(java.lang.String type) |
void |
setLongProperty(java.lang.String name,
long value)
Sets a
long property value with the specified name into
the message. |
void |
setObjectProperty(java.lang.String name,
java.lang.Object value)
Sets a Java object property value with the specified name into the
message.
|
void |
setSequenceNumber(java.lang.String sequenceNumber)
This method sets the JMS_SQS_SEQUENCE_NUMBER property on the message.
|
void |
setShortProperty(java.lang.String name,
short value)
Sets a
short property value with the specified name into
the message. |
void |
setSQSMessageId(java.lang.String sqsMessageID)
Set SQS Message Id, used on send.
|
void |
setStringProperty(java.lang.String name,
java.lang.String value)
Sets a
String property value with the specified name into
the message. |
public static final java.lang.String BYTE_MESSAGE_TYPE
public static final java.lang.String OBJECT_MESSAGE_TYPE
public static final java.lang.String TEXT_MESSAGE_TYPE
public static final java.lang.String JMS_SQS_MESSAGE_TYPE
public static final java.lang.String JMS_SQS_REPLY_TO_QUEUE_NAME
public static final java.lang.String JMS_SQS_REPLY_TO_QUEUE_URL
protected void checkPropertyWritePermissions()
throws JMSException
JMSExceptionprotected void checkBodyWritePermissions()
throws JMSException
JMSExceptionprotected static JMSException convertExceptionToJMSException(java.lang.Exception e)
protected static MessageFormatException convertExceptionToMessageFormatException(java.lang.Exception e)
protected void setBodyWritePermissions(boolean enable)
public java.lang.String getSQSMessageGroupId()
throws JMSException
JMSExceptionpublic java.lang.String getSQSMessageDeduplicationId()
throws JMSException
JMSExceptionpublic java.lang.String getSQSMessageSequenceNumber()
throws JMSException
JMSExceptionpublic java.lang.String getSQSMessageId()
public void setSQSMessageId(java.lang.String sqsMessageID)
throws JMSException
sqsMessageID - messageId assigned by SQS during send.JMSExceptionpublic java.lang.String getReceiptHandle()
public java.lang.String getQueueUrl()
public java.lang.String getJMSMessageID()
throws JMSException
The JMSMessageID header field contains a value that uniquely identifies each message sent by a provider. It is set to SQS messageId with the prefix 'ID:'.
JMSExceptionpublic void setJMSMessageID(java.lang.String id)
throws JMSException
Set when a message is sent. This method can be used to change the value for a message that has been received.
id - The ID of the message.JMSExceptionpublic long getJMSTimestamp()
throws JMSException
JMSExceptionpublic void setJMSTimestamp(long timestamp)
throws JMSException
JMSExceptionpublic byte[] getJMSCorrelationIDAsBytes()
throws JMSException
JMSExceptionpublic void setJMSCorrelationIDAsBytes(byte[] correlationID)
throws JMSException
JMSExceptionpublic void setJMSCorrelationID(java.lang.String correlationID)
throws JMSException
JMSExceptionpublic java.lang.String getJMSCorrelationID()
throws JMSException
JMSExceptionpublic Destination getJMSReplyTo()
throws JMSException
JMSExceptionpublic void setJMSReplyTo(Destination replyTo)
throws JMSException
JMSExceptionpublic Destination getJMSDestination()
throws JMSException
The JMSDestination header field contains the destination to which the message is being sent.
When a message is sent, this field is ignored. After completion of the send or publish method, the field holds the destination specified by the method.
When a message is received, its JMSDestination value must be equivalent to the value assigned when it was sent.
JMSExceptionpublic void setJMSDestination(Destination destination)
throws JMSException
Set when a message is sent. This method can be used to change the value for a message that has been received.
destination - The destination for this message.JMSExceptionpublic int getJMSDeliveryMode()
throws JMSException
JMSExceptionpublic void setJMSDeliveryMode(int deliveryMode)
throws JMSException
JMSExceptionpublic boolean getJMSRedelivered()
throws JMSException
JMSExceptionpublic void setJMSRedelivered(boolean redelivered)
throws JMSException
JMSExceptionpublic java.lang.String getJMSType()
throws JMSException
JMSExceptionpublic void setJMSType(java.lang.String type)
throws JMSException
JMSExceptionpublic long getJMSExpiration()
throws JMSException
JMSExceptionpublic void setJMSExpiration(long expiration)
throws JMSException
JMSExceptionpublic int getJMSPriority()
throws JMSException
JMSExceptionpublic void setJMSPriority(int priority)
throws JMSException
JMSExceptionpublic void clearProperties()
throws JMSException
JMSExceptionpublic boolean propertyExists(java.lang.String name)
throws JMSException
name - The name of the property.JMSExceptionpublic boolean getBooleanProperty(java.lang.String name)
throws JMSException
boolean property with the specified
name.name - The name of the property to get.boolean property value for the specified name.JMSException - On internal error.MessageFormatException - If the property cannot be converted to the specified type.java.lang.NullPointerException - When property name is null.public byte getByteProperty(java.lang.String name)
throws JMSException
byte property with the specified
name.name - The name of the property to get.byte property value for the specified name.JMSException - On internal error.MessageFormatException - If the property cannot be converted to the specified type.java.lang.NullPointerException - When property name is null.java.lang.NumberFormatException - When property value is null.public short getShortProperty(java.lang.String name)
throws JMSException
short property with the specified
name.name - The name of the property to get.short property value for the specified name.JMSException - On internal error.MessageFormatException - If the property cannot be converted to the specified type.java.lang.NullPointerException - When property name is null.java.lang.NumberFormatException - When property value is null.public int getIntProperty(java.lang.String name)
throws JMSException
int property with the specified
name.name - The name of the property to get.int property value for the specified name.JMSException - On internal error.MessageFormatException - If the property cannot be converted to the specified type.java.lang.NullPointerException - When property name is null.java.lang.NumberFormatException - When property value is null.public long getLongProperty(java.lang.String name)
throws JMSException
long property with the specified
name.name - The name of the property to get.long property value for the specified name.JMSException - On internal error.MessageFormatException - If the property cannot be converted to the specified type.java.lang.NullPointerException - When property name is null.java.lang.NumberFormatException - When property value is null.public float getFloatProperty(java.lang.String name)
throws JMSException
float property with the specified
name.name - The name of the property to get.float property value for the specified name.JMSException - Wn internal error.MessageFormatException - If the property cannot be converted to the specified type.java.lang.NullPointerException - When property name or value is null.public double getDoubleProperty(java.lang.String name)
throws JMSException
double property with the specified
name.name - The name of the property to get.double property value for the specified name.JMSException - On internal error.MessageFormatException - If the property cannot be converted to the specified type.java.lang.NullPointerException - When property name or value is null.public java.lang.String getStringProperty(java.lang.String name)
throws JMSException
String property with the specified
name.name - The name of the property to get.String property value for the specified name.JMSException - On internal error.MessageFormatException - If the property cannot be converted to the specified type.java.lang.NullPointerException - When property name is null.public java.lang.Object getObjectProperty(java.lang.String name)
throws JMSException
This method can be used to return, in boxed format, an object that has
been stored as a property in the message with the equivalent
setObjectProperty method call, or its equivalent primitive
setter method.
name - The name of the property to get.int, an Integer is returned); if there
is no property by this name, a null value is returned.JMSException - On internal error.public SQSMessage.JMSMessagePropertyValue getJMSMessagePropertyValue(java.lang.String name) throws JMSException
name - The name of the property to get.JMSMessagePropertyValue with object value and
corresponding SQS message attribute type and message attribute
string value.JMSException - On internal error.public java.util.Enumeration<java.lang.String> getPropertyNames()
throws JMSException
Enumeration of all the property names.
Note that JMS standard header fields are not considered properties and are not returned in this enumeration.
JMSException - On internal error.public void setBooleanProperty(java.lang.String name,
boolean value)
throws JMSException
boolean property value with the specified name into
the message.name - The name of the property to set.value - The boolean value of the property to set.JMSException - On internal error.java.lang.IllegalArgumentException - If the name or value is null or empty string.MessageNotWriteableException - If properties are read-only.public void setByteProperty(java.lang.String name,
byte value)
throws JMSException
byte property value with the specified name into
the message.name - The name of the property to set.value - The byte value of the property to set.JMSException - On internal error.java.lang.IllegalArgumentException - If the name or value is null or empty string.MessageNotWriteableException - If properties are read-only.public void setShortProperty(java.lang.String name,
short value)
throws JMSException
short property value with the specified name into
the message.name - The name of the property to set.value - The short value of the property to set.JMSException - On internal error.java.lang.IllegalArgumentException - If the name or value is null or empty string.MessageNotWriteableException - If properties are read-only.public void setIntProperty(java.lang.String name,
int value)
throws JMSException
int property value with the specified name into
the message.name - The name of the property to set.value - The int value of the property to set.JMSException - On internal error.java.lang.IllegalArgumentException - If the name or value is null or empty string.MessageNotWriteableException - If properties are read-only.public void setLongProperty(java.lang.String name,
long value)
throws JMSException
long property value with the specified name into
the message.name - The name of the property to set.value - The long value of the property to set.JMSException - On internal error.java.lang.IllegalArgumentException - If the name or value is null or empty string.MessageNotWriteableException - If properties are read-only.public void setFloatProperty(java.lang.String name,
float value)
throws JMSException
float property value with the specified name into
the message.name - The name of the property to set.value - The float value of the property to set.JMSException - On internal error.java.lang.IllegalArgumentException - If the name or value is null or empty string.MessageNotWriteableException - If properties are read-only.public void setDoubleProperty(java.lang.String name,
double value)
throws JMSException
double property value with the specified name into
the message.name - The name of the property to set.value - The double value of the property to set.JMSException - On internal error.java.lang.IllegalArgumentException - If the name or value is null or empty string.MessageNotWriteableException - If properties are read-only.public void setStringProperty(java.lang.String name,
java.lang.String value)
throws JMSException
String property value with the specified name into
the message.name - The name of the property to set.value - The String value of the property to set.JMSException - On internal error.java.lang.IllegalArgumentException - If the name or value is null or empty string.MessageNotWriteableException - If properties are read-only.public void setObjectProperty(java.lang.String name,
java.lang.Object value)
throws JMSException
Note that this method works only for the boxed primitive object types (Integer, Double, Long ...) and String objects.
name - The name of the property to set.value - The object value of the property to set.JMSException - On internal error.java.lang.IllegalArgumentException - If the name or value is null or empty string.MessageFormatException - If the object is invalid type.MessageNotWriteableException - If properties are read-only.public void acknowledge()
throws JMSException
Acknowledges message(s).
A client may individually acknowledge each message as it is consumed, or it may choose to acknowledge multiple messages based on acknowledge mode, which in turn might might acknowledge all messages consumed by the session.
Messages that have been received but not acknowledged may be redelivered.
If the session is closed, messages cannot be acknowledged.
If only the consumer is closed, messages can still be acknowledged.
JMSException - On Internal errorjava.lang.IllegalStateException - If this method is called on a closed session.AcknowledgeModepublic void clearBody()
throws JMSException
Clears out the message body. Clearing a message's body does not clear its header values or property entries.
This method cannot be called directly instead the implementation on the subclasses should be used.
JMSException - If directly calledpublic void setSequenceNumber(java.lang.String sequenceNumber)
throws JMSException
sequenceNumber - Sequence number to set. If null or empty, the stored sequence number will be removed.JMSException