Class SnsNotification<T>
java.lang.Object
io.awspring.cloud.sqs.support.converter.SnsNotification<T>
- Type Parameters:
T- the type of the message payload
Wrapper for SNS notifications that provides access to both the message payload and metadata.
Example usage:
@SqsListener("my-queue")
public void handleMessage( @SnsNotification SnsNotification<String> notification) {
String messageId = notification.getMessageId();
String topicArn = notification.getTopicArn();
Optional<String> subject = notification.getSubject();
String message = notification.getMessage();
Instant timestamp = notification.getTimestamp();
Map<String, MessageAttribute> attributes = notification.getMessageAttributes();
// Process the notification...
}
- Since:
- 3.4.1
- Author:
- Damien Chomat
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents an SNS message attribute. -
Constructor Summary
ConstructorsConstructorDescriptionSnsNotification(String type, String messageId, String topicArn, T message, String timestamp, Map<String, SnsNotification.MessageAttribute> messageAttributes, String sequenceNumber, String subject, String unsubscribeURL, String signature, String signatureVersion, String signingCertURL) -
Method Summary
Modifier and TypeMethodDescriptionGets the message payload.Gets the message attributes.Gets the message ID.Gets the sequence number.Gets the signature.Gets the signature version.Gets the signing certificate URL.Gets the subject.Gets the timestamp.Gets the topic ARN.getType()Gets the notification type.Gets the unsubscribe URL.
-
Constructor Details
-
SnsNotification
public SnsNotification(String type, String messageId, String topicArn, T message, String timestamp, @Nullable Map<String, SnsNotification.MessageAttribute> messageAttributes, @Nullable String sequenceNumber, @Nullable String subject, @Nullable String unsubscribeURL, @Nullable String signature, @Nullable String signatureVersion, @Nullable String signingCertURL)
-
-
Method Details
-
getMessageId
Gets the message ID.- Returns:
- the message ID (required field, unique identifier assigned by SNS)
-
getTopicArn
Gets the topic ARN.- Returns:
- the topic ARN (required field, ARN of the topic that published the message)
-
getMessage
Gets the message payload.- Returns:
- the message payload (required field, the actual content of the notification)
-
getTimestamp
Gets the timestamp.- Returns:
- the timestamp (required field, when the notification was published in ISO-8601 format)
-
getMessageAttributes
Gets the message attributes.- Returns:
- the message attributes (optional field, custom attributes attached to the message)
-
getType
Gets the notification type.- Returns:
- the notification type (required field, always "Notification" for standard SNS messages)
-
getSubject
Gets the subject.- Returns:
- the subject (optional field, title/subject set when publishing), or empty if not present
-
getSequenceNumber
Gets the sequence number.- Returns:
- the sequence number (optional field, present only for FIFO topics), or empty if not present
-
getUnsubscribeUrl
Gets the unsubscribe URL.- Returns:
- the unsubscribe URL (optional field, URL to unsubscribe from the topic), or empty if not present
-
getSignatureVersion
Gets the signature version.- Returns:
- the signature version (optional field, present when message signing is enabled), or empty if not present
-
getSignature
Gets the signature.- Returns:
- the signature (optional field, present when message signing is enabled), or empty if not present
-
getSigningCertURL
Gets the signing certificate URL.- Returns:
- the signing certificate URL (optional field, present when message signing is enabled), or empty if not present
-