Class SQSObjectMessage
- java.lang.Object
-
- com.amazon.sqs.javamessaging.message.SQSMessage
-
- com.amazon.sqs.javamessaging.message.SQSObjectMessage
-
- All Implemented Interfaces:
javax.jms.Message
,javax.jms.ObjectMessage
public class SQSObjectMessage extends SQSMessage implements javax.jms.ObjectMessage
An ObjectMessage object is used to send a message that contains a Java serializable object.It inherits from the Message interface and adds a body containing a single reference to an object. Only Serializable Java objects can be used.
When a client receives an ObjectMessage, it is in read-only mode. If a client attempts to write to the message at this point, a MessageNotWriteableException is thrown. If clearBody is called, the message can now be both read from and written to.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.amazon.sqs.javamessaging.message.SQSMessage
SQSMessage.JMSMessagePropertyValue, SQSMessage.TypeConversionSupport
-
-
Field Summary
-
Fields inherited from class com.amazon.sqs.javamessaging.message.SQSMessage
BYTE_MESSAGE_TYPE, JMS_SQS_CORRELATION_ID, JMS_SQS_MESSAGE_TYPE, JMS_SQS_REPLY_TO_QUEUE_NAME, JMS_SQS_REPLY_TO_QUEUE_URL, OBJECT_MESSAGE_TYPE, TEXT_MESSAGE_TYPE
-
-
Constructor Summary
Constructors Constructor Description SQSObjectMessage()
Create new empty ObjectMessage to send.SQSObjectMessage(Acknowledger acknowledger, String queueUrl, software.amazon.awssdk.services.sqs.model.Message sqsMessage)
Convert received SQSMessage into ObjectMessageSQSObjectMessage(Serializable payload)
Create new ObjectMessage with payload to send.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearBody()
Sets the message body to write mode, and sets the object body to nullprotected static Serializable
deserialize(String serialized)
Deserialize theString
intoSerializable
object.String
getMessageBody()
Serializable
getObject()
Gets theSerializable
containing this message's bodyprotected static String
serialize(Serializable serializable)
Serialize theSerializable
object toString
.void
setObject(Serializable payload)
Sets theSerializable
containing this message's body-
Methods inherited from class com.amazon.sqs.javamessaging.message.SQSMessage
acknowledge, checkBodyWritePermissions, checkPropertyWritePermissions, clearProperties, convertExceptionToJMSException, convertExceptionToMessageFormatException, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSMessagePropertyValue, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getQueueUrl, getReceiptHandle, getShortProperty, getSQSMessageDeduplicationId, getSQSMessageGroupId, getSQSMessageId, getSQSMessageSequenceNumber, getStringProperty, propertyExists, setBodyWritePermissions, setBooleanProperty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setSequenceNumber, setShortProperty, setSQSMessageId, setStringProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.jms.Message
acknowledge, clearProperties, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, propertyExists, setBooleanProperty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setShortProperty, setStringProperty
-
-
-
-
Constructor Detail
-
SQSObjectMessage
public SQSObjectMessage(Acknowledger acknowledger, String queueUrl, software.amazon.awssdk.services.sqs.model.Message sqsMessage) throws javax.jms.JMSException
Convert received SQSMessage into ObjectMessage- Throws:
javax.jms.JMSException
-
SQSObjectMessage
public SQSObjectMessage() throws javax.jms.JMSException
Create new empty ObjectMessage to send.- Throws:
javax.jms.JMSException
-
SQSObjectMessage
public SQSObjectMessage(Serializable payload) throws javax.jms.JMSException
Create new ObjectMessage with payload to send.- Throws:
javax.jms.JMSException
-
-
Method Detail
-
setObject
public void setObject(Serializable payload) throws javax.jms.JMSException
Sets theSerializable
containing this message's body- Specified by:
setObject
in interfacejavax.jms.ObjectMessage
- Parameters:
payload
- TheSerializable
containing the message's body- Throws:
MessageNotWriteableException
- If the message is in read-only mode.MessageFormatException
- If object serialization fails.javax.jms.JMSException
-
getObject
public Serializable getObject() throws javax.jms.JMSException
Gets theSerializable
containing this message's body- Specified by:
getObject
in interfacejavax.jms.ObjectMessage
- Throws:
MessageFormatException
- If object deserialization fails.javax.jms.JMSException
-
clearBody
public void clearBody() throws javax.jms.JMSException
Sets the message body to write mode, and sets the object body to null- Specified by:
clearBody
in interfacejavax.jms.Message
- Overrides:
clearBody
in classSQSMessage
- Throws:
javax.jms.JMSException
- If directly called
-
deserialize
protected static Serializable deserialize(String serialized) throws javax.jms.JMSException
Deserialize theString
intoSerializable
object.- Throws:
javax.jms.JMSException
-
serialize
protected static String serialize(Serializable serializable) throws javax.jms.JMSException
Serialize theSerializable
object toString
.- Throws:
javax.jms.JMSException
-
getMessageBody
public String getMessageBody()
-
-