Class SQSObjectMessage
java.lang.Object
com.amazon.sqs.javamessaging.message.SQSMessage
com.amazon.sqs.javamessaging.message.SQSObjectMessage
- All Implemented Interfaces:
jakarta.jms.Message,jakarta.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_TYPEFields inherited from interface jakarta.jms.Message
DEFAULT_DELIVERY_DELAY, DEFAULT_DELIVERY_MODE, DEFAULT_PRIORITY, DEFAULT_TIME_TO_LIVE -
Constructor Summary
ConstructorsConstructorDescriptionCreate 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
Modifier and TypeMethodDescriptionvoidSets the message body to write mode, and sets the object body to nullprotected static Serializabledeserialize(String serialized) Deserialize theStringintoSerializableobject.Gets theSerializablecontaining this message's bodyprotected static Stringserialize(Serializable serializable) Serialize theSerializableobject toString.voidsetObject(Serializable payload) Sets theSerializablecontaining this message's bodyMethods inherited from class com.amazon.sqs.javamessaging.message.SQSMessage
acknowledge, checkBodyWritePermissions, checkPropertyWritePermissions, clearProperties, convertExceptionToJMSException, convertExceptionToMessageFormatException, getBody, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDeliveryTime, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSMessagePropertyValue, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getQueueUrl, getReceiptHandle, getShortProperty, getSQSMessageDeduplicationId, getSQSMessageGroupId, getSQSMessageId, getSQSMessageSequenceNumber, getStringProperty, isBodyAssignableTo, propertyExists, setBodyWritePermissions, setBooleanProperty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDeliveryTime, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setSequenceNumber, setShortProperty, setSQSMessageId, setStringPropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.jms.Message
acknowledge, clearProperties, getBody, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDeliveryTime, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, isBodyAssignableTo, propertyExists, setBooleanProperty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDeliveryTime, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setShortProperty, setStringProperty
-
Constructor Details
-
SQSObjectMessage
public SQSObjectMessage(Acknowledger acknowledger, String queueUrl, software.amazon.awssdk.services.sqs.model.Message sqsMessage) throws jakarta.jms.JMSException Convert received SQSMessage into ObjectMessage- Throws:
jakarta.jms.JMSException
-
SQSObjectMessage
public SQSObjectMessage() throws jakarta.jms.JMSExceptionCreate new empty ObjectMessage to send.- Throws:
jakarta.jms.JMSException
-
SQSObjectMessage
Create new ObjectMessage with payload to send.- Throws:
jakarta.jms.JMSException
-
-
Method Details
-
setObject
Sets theSerializablecontaining this message's body- Specified by:
setObjectin interfacejakarta.jms.ObjectMessage- Parameters:
payload- TheSerializablecontaining the message's body- Throws:
jakarta.jms.MessageNotWriteableException- If the message is in read-only mode.jakarta.jms.MessageFormatException- If object serialization fails.jakarta.jms.JMSException
-
getObject
Gets theSerializablecontaining this message's body- Specified by:
getObjectin interfacejakarta.jms.ObjectMessage- Throws:
jakarta.jms.MessageFormatException- If object deserialization fails.jakarta.jms.JMSException
-
clearBody
public void clearBody() throws jakarta.jms.JMSExceptionSets the message body to write mode, and sets the object body to null- Specified by:
clearBodyin interfacejakarta.jms.Message- Overrides:
clearBodyin classSQSMessage- Throws:
jakarta.jms.JMSException- If directly called
-
deserialize
Deserialize theStringintoSerializableobject.- Throws:
jakarta.jms.JMSException
-
serialize
Serialize theSerializableobject toString.- Throws:
jakarta.jms.JMSException
-
getMessageBody
-