Class SnsInboundChannelAdapter

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.MessagingGatewaySupport
org.springframework.integration.http.inbound.BaseHttpInboundEndpoint
org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport
org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway
org.springframework.integration.aws.inbound.SnsInboundChannelAdapter
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.context.OrderlyShutdownCapable, org.springframework.integration.IntegrationPattern, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationInboundManagement, org.springframework.integration.support.management.IntegrationManagement, org.springframework.integration.support.management.ManageableLifecycle, org.springframework.integration.support.management.ManageableSmartLifecycle, org.springframework.integration.support.management.TrackableComponent, org.springframework.web.HttpRequestHandler

public class SnsInboundChannelAdapter extends org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway
The HttpRequestHandlingMessagingGateway extension for the Amazon WS SNS HTTP(S) endpoints. Accepts all x-amz-sns-message-types, converts the received Topic JSON message to the Map using MappingJackson2HttpMessageConverter and send it to the provided MessagingGatewaySupport.getRequestChannel() as Message payload.

The mapped url must be configured inside the Amazon Web Service platform as a subscription. Before receiving any notification itself this HTTP endpoint must confirm the subscription.

The handleNotificationStatus flag (defaults to false) indicates that this endpoint should send the SubscriptionConfirmation/UnsubscribeConfirmation messages to the provided MessagingGatewaySupport.getRequestChannel(). If that, the AwsHeaders.NOTIFICATION_STATUS header is populated with the NotificationStatus value. In that case it is a responsibility of the application to NotificationStatus.confirmSubscription() or not.

By default, this endpoint just does NotificationStatus.confirmSubscription() for the SubscriptionConfirmation message type. And does nothing for the UnsubscribeConfirmation.

For the convenience on the underlying message flow routing a AwsHeaders.SNS_MESSAGE_TYPE header is present.

Author:
Artem Bilan, Kamil Przerwa
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.integration.gateway.MessagingGatewaySupport

    org.springframework.integration.gateway.MessagingGatewaySupport.ConvertingMessagingTemplate

    Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement

    org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides
  • Field Summary

    Fields inherited from class org.springframework.integration.http.inbound.BaseHttpInboundEndpoint

    activeCount, JAXB_PRESENT, NON_READABLE_BODY_HTTP_METHODS, ROME_TOOLS_PRESENT

    Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport

    messagingTemplate

    Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint

    lifecycleCondition, lifecycleLock

    Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport

    EXPRESSION_PARSER, logger

    Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement

    METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors
    Constructor
    Description
    SnsInboundChannelAdapter(software.amazon.awssdk.services.sns.SnsClient amazonSns, String... path)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    protected void
     
    protected void
    send(Object object)
     
    void
    setExtractReplyPayload(boolean extractReplyPayload)
     
    void
    setHandleNotificationStatus(boolean handleNotificationStatus)
     
    void
    setHeaderExpressions(Map<String,org.springframework.expression.Expression> headerExpressions)
     
    void
    setHeaderMapper(org.springframework.integration.mapping.HeaderMapper<org.springframework.http.HttpHeaders> headerMapper)
     
    void
    setMergeWithDefaultConverters(boolean mergeWithDefaultConverters)
     
    void
    setMessageConverters(List<org.springframework.http.converter.HttpMessageConverter<?>> messageConverters)
     
    void
    setMultipartResolver(org.springframework.web.multipart.MultipartResolver multipartResolver)
     
    void
    setPayloadExpression(org.springframework.expression.Expression payloadExpression)
     
    void
    setRequestMapping(org.springframework.integration.http.inbound.RequestMapping requestMapping)
     
    void
    setRequestPayloadTypeClass(Class<?> requestPayloadType)
     
    void
    setStatusCodeExpression(org.springframework.expression.Expression statusCodeExpression)
     

    Methods inherited from class org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway

    handleRequest, setConvertExceptions

    Methods inherited from class org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport

    doHandleRequest, extractRequestBody, getMessageConverters, prepareRequest, prepareRequestEntity, setStatusCodeIfNeeded, setupResponseAndConvertReply

    Methods inherited from class org.springframework.integration.http.inbound.BaseHttpInboundEndpoint

    afterShutdown, beforeShutdown, createEvaluationContext, evaluateHttpStatus, getCrossOrigin, getExtractReplyPayload, getHeaderExpressions, getHeaderMapper, getIntegrationPatternType, getPayloadExpression, getRequestMapping, getRequestPayloadType, getStatusCodeExpression, getValidator, isExpectReply, isReadable, resolveHttpStatusFromHeaders, setCrossOrigin, setRequestPayloadType, setStatusCodeExpressionString, setValidator, validate

    Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport

    buildErrorMessage, buildSendTimer, destroy, doStart, doStop, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, isObserved, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerObservationRegistry, registerReplyMessageCorrelatorIfNecessary, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, setObservationConvention, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrack

    Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint

    doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop

    Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport

    afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement

    getThisAs

    Methods inherited from interface org.springframework.integration.support.context.NamedComponent

    getBeanName, getComponentName
  • Constructor Details

    • SnsInboundChannelAdapter

      public SnsInboundChannelAdapter(software.amazon.awssdk.services.sns.SnsClient amazonSns, String... path)
  • Method Details

    • setHandleNotificationStatus

      public void setHandleNotificationStatus(boolean handleNotificationStatus)
    • onInit

      protected void onInit()
      Overrides:
      onInit in class org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport
    • getComponentType

      public String getComponentType()
      Specified by:
      getComponentType in interface org.springframework.integration.support.context.NamedComponent
      Overrides:
      getComponentType in class org.springframework.integration.http.inbound.BaseHttpInboundEndpoint
    • send

      protected void send(Object object)
      Overrides:
      send in class org.springframework.integration.gateway.MessagingGatewaySupport
    • setPayloadExpression

      public void setPayloadExpression(org.springframework.expression.Expression payloadExpression)
      Overrides:
      setPayloadExpression in class org.springframework.integration.http.inbound.BaseHttpInboundEndpoint
    • setHeaderExpressions

      public void setHeaderExpressions(Map<String,org.springframework.expression.Expression> headerExpressions)
      Overrides:
      setHeaderExpressions in class org.springframework.integration.http.inbound.BaseHttpInboundEndpoint
    • setMessageConverters

      public void setMessageConverters(List<org.springframework.http.converter.HttpMessageConverter<?>> messageConverters)
      Overrides:
      setMessageConverters in class org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport
    • setMergeWithDefaultConverters

      public void setMergeWithDefaultConverters(boolean mergeWithDefaultConverters)
      Overrides:
      setMergeWithDefaultConverters in class org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport
    • setHeaderMapper

      public void setHeaderMapper(org.springframework.integration.mapping.HeaderMapper<org.springframework.http.HttpHeaders> headerMapper)
      Overrides:
      setHeaderMapper in class org.springframework.integration.http.inbound.BaseHttpInboundEndpoint
    • setRequestMapping

      public void setRequestMapping(org.springframework.integration.http.inbound.RequestMapping requestMapping)
      Overrides:
      setRequestMapping in class org.springframework.integration.http.inbound.BaseHttpInboundEndpoint
    • setRequestPayloadTypeClass

      public void setRequestPayloadTypeClass(Class<?> requestPayloadType)
      Overrides:
      setRequestPayloadTypeClass in class org.springframework.integration.http.inbound.BaseHttpInboundEndpoint
    • setExtractReplyPayload

      public void setExtractReplyPayload(boolean extractReplyPayload)
      Overrides:
      setExtractReplyPayload in class org.springframework.integration.http.inbound.BaseHttpInboundEndpoint
    • setMultipartResolver

      public void setMultipartResolver(org.springframework.web.multipart.MultipartResolver multipartResolver)
      Overrides:
      setMultipartResolver in class org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport
    • setStatusCodeExpression

      public void setStatusCodeExpression(org.springframework.expression.Expression statusCodeExpression)
      Overrides:
      setStatusCodeExpression in class org.springframework.integration.http.inbound.BaseHttpInboundEndpoint