Class SnsNotification<T>

java.lang.Object
io.awspring.cloud.sqs.support.converter.SnsNotification<T>
Type Parameters:
T - the type of the message payload

public class SnsNotification<T> extends Object
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:
  • Constructor Details

  • Method Details

    • getMessageId

      public String getMessageId()
      Gets the message ID.
      Returns:
      the message ID (required field, unique identifier assigned by SNS)
    • getTopicArn

      public String getTopicArn()
      Gets the topic ARN.
      Returns:
      the topic ARN (required field, ARN of the topic that published the message)
    • getMessage

      public T getMessage()
      Gets the message payload.
      Returns:
      the message payload (required field, the actual content of the notification)
    • getTimestamp

      public String getTimestamp()
      Gets the timestamp.
      Returns:
      the timestamp (required field, when the notification was published in ISO-8601 format)
    • getMessageAttributes

      public Map<String,SnsNotification.MessageAttribute> getMessageAttributes()
      Gets the message attributes.
      Returns:
      the message attributes (optional field, custom attributes attached to the message)
    • getType

      public String getType()
      Gets the notification type.
      Returns:
      the notification type (required field, always "Notification" for standard SNS messages)
    • getSubject

      public Optional<String> getSubject()
      Gets the subject.
      Returns:
      the subject (optional field, title/subject set when publishing), or empty if not present
    • getSequenceNumber

      public Optional<String> getSequenceNumber()
      Gets the sequence number.
      Returns:
      the sequence number (optional field, present only for FIFO topics), or empty if not present
    • getUnsubscribeUrl

      public Optional<String> getUnsubscribeUrl()
      Gets the unsubscribe URL.
      Returns:
      the unsubscribe URL (optional field, URL to unsubscribe from the topic), or empty if not present
    • getSignatureVersion

      public Optional<String> getSignatureVersion()
      Gets the signature version.
      Returns:
      the signature version (optional field, present when message signing is enabled), or empty if not present
    • getSignature

      public Optional<String> getSignature()
      Gets the signature.
      Returns:
      the signature (optional field, present when message signing is enabled), or empty if not present
    • getSigningCertURL

      public Optional<String> getSigningCertURL()
      Gets the signing certificate URL.
      Returns:
      the signing certificate URL (optional field, present when message signing is enabled), or empty if not present