Class KplMessageHandler

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractMessageProducingHandler
io.awspring.cloud.kinesis.integration.KplMessageHandler
All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>, Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, Lifecycle, Ordered, org.springframework.integration.context.ComponentSourceAware, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.context.Orderable, org.springframework.integration.core.MessageProducer, org.springframework.integration.handler.HeaderPropagationAware, org.springframework.integration.IntegrationPattern, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationManagement, org.springframework.integration.support.management.TrackableComponent, MessageHandler, reactor.core.CoreSubscriber<Message<?>>

public class KplMessageHandler extends org.springframework.integration.handler.AbstractMessageProducingHandler implements Lifecycle
The AbstractMessageHandler implementation for the Amazon Kinesis Producer Library putRecord(s).

The KplBackpressureException is thrown when backpressure handling is enabled and buffer is at max capacity. This exception can be handled with AbstractRequestHandlerAdvice.

Since:
4.0
Author:
Arnaud Lecollaire, Artem Bilan, Siddharth Jain
  • Nested Class Summary

    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.handler.AbstractMessageProducingHandler

    messagingTemplate

    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.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    KplMessageHandler(software.amazon.kinesis.producer.KinesisProducer kinesisProducer)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    boolean
     
    protected void
     
    void
    setBackPressureThreshold(long backPressureThreshold)
    Configure maximum records in flight for handling backpressure.
    void
    setEmbeddedHeadersMapper(org.springframework.integration.mapping.OutboundMessageMapper<byte[]> embeddedHeadersMapper)
    Specify a OutboundMessageMapper for embedding message headers into the record data together with payload.
    void
    setExplicitHashKey(String explicitHashKey)
     
    void
    setExplicitHashKeyExpression(Expression explicitHashKeyExpression)
     
    void
    setExplicitHashKeyExpressionString(String explicitHashKeyExpression)
     
    void
    setFlushDuration(Duration flushDuration)
    Configure a Duration how often to call a KinesisProducer.flush().
    void
    setGlueSchema(com.amazonaws.services.schemaregistry.common.Schema glueSchema)
    Set a Schema to add into a UserRecord built from the request message.
    void
    setGlueSchemaExpression(Expression glueSchemaExpression)
    Set a SpEL expression for Schema to add into a UserRecord built from the request message.
    void
    setGlueSchemaExpressionString(String glueSchemaExpression)
    Set a SpEL expression for Schema to add into a UserRecord built from the request message.
    void
    Configure a MessageConverter for converting payload to byte[] for Kinesis record.
    void
    setPartitionKey(String partitionKey)
     
    void
    setPartitionKeyExpression(Expression partitionKeyExpression)
     
    void
    setPartitionKeyExpressionString(String partitionKeyExpression)
     
    void
    setSendTimeout(long sendTimeout)
     
    void
    setSendTimeoutExpression(Expression sendTimeoutExpression)
     
    void
    setSendTimeoutExpressionString(String sendTimeoutExpression)
     
    void
    setStream(String stream)
     
    void
    setStreamExpression(Expression streamExpression)
     
    void
     
    void
     
    void
     

    Methods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler

    addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setupMessageProcessor, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeaders

    Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler

    handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConvention

    Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport

    buildSendTimer, destroy, getComponentType, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack

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

    afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, 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 reactor.core.CoreSubscriber

    currentContext

    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

    • KplMessageHandler

      public KplMessageHandler(software.amazon.kinesis.producer.KinesisProducer kinesisProducer)
  • Method Details

    • setBackPressureThreshold

      public void setBackPressureThreshold(long backPressureThreshold)
      Configure maximum records in flight for handling backpressure. By default, backpressure handling is not enabled. When backpressure handling is enabled and number of records in flight exceeds the threshold, a KplBackpressureException would be thrown.
      Parameters:
      backPressureThreshold - a value greater than 0 to enable backpressure handling.
    • setMessageConverter

      public void setMessageConverter(MessageConverter messageConverter)
      Configure a MessageConverter for converting payload to byte[] for Kinesis record.
      Parameters:
      messageConverter - the MessageConverter to use.
    • setStream

      public void setStream(String stream)
    • setStreamExpressionString

      public void setStreamExpressionString(String streamExpression)
    • setStreamExpression

      public void setStreamExpression(Expression streamExpression)
    • setPartitionKey

      public void setPartitionKey(String partitionKey)
    • setPartitionKeyExpressionString

      public void setPartitionKeyExpressionString(String partitionKeyExpression)
    • setPartitionKeyExpression

      public void setPartitionKeyExpression(Expression partitionKeyExpression)
    • setExplicitHashKey

      public void setExplicitHashKey(String explicitHashKey)
    • setExplicitHashKeyExpressionString

      public void setExplicitHashKeyExpressionString(String explicitHashKeyExpression)
    • setExplicitHashKeyExpression

      public void setExplicitHashKeyExpression(Expression explicitHashKeyExpression)
    • setEmbeddedHeadersMapper

      public void setEmbeddedHeadersMapper(org.springframework.integration.mapping.OutboundMessageMapper<byte[]> embeddedHeadersMapper)
      Specify a OutboundMessageMapper for embedding message headers into the record data together with payload.
      Parameters:
      embeddedHeadersMapper - the OutboundMessageMapper to embed headers into the record data.
    • setFlushDuration

      public void setFlushDuration(Duration flushDuration)
      Configure a Duration how often to call a KinesisProducer.flush().
      Parameters:
      flushDuration - the Duration to periodic call of a KinesisProducer.flush().
    • setGlueSchema

      public void setGlueSchema(com.amazonaws.services.schemaregistry.common.Schema glueSchema)
      Set a Schema to add into a UserRecord built from the request message.
      Parameters:
      glueSchema - the Schema to add into a UserRecord.
      See Also:
      • UserRecord.setSchema(Schema)
    • setGlueSchemaExpressionString

      public void setGlueSchemaExpressionString(String glueSchemaExpression)
      Set a SpEL expression for Schema to add into a UserRecord built from the request message.
      Parameters:
      glueSchemaExpression - the SpEL expression to evaluate a Schema.
      See Also:
      • UserRecord.setSchema(Schema)
    • setGlueSchemaExpression

      public void setGlueSchemaExpression(Expression glueSchemaExpression)
      Set a SpEL expression for Schema to add into a UserRecord built from the request message.
      Parameters:
      glueSchemaExpression - the SpEL expression to evaluate a Schema.
      See Also:
      • UserRecord.setSchema(Schema)
    • setSendTimeout

      public void setSendTimeout(long sendTimeout)
      Overrides:
      setSendTimeout in class org.springframework.integration.handler.AbstractMessageProducingHandler
    • setSendTimeoutExpressionString

      public void setSendTimeoutExpressionString(String sendTimeoutExpression)
    • setSendTimeoutExpression

      public void setSendTimeoutExpression(Expression sendTimeoutExpression)
    • onInit

      protected void onInit()
      Overrides:
      onInit in class org.springframework.integration.handler.AbstractMessageProducingHandler
    • start

      public void start()
      Specified by:
      start in interface Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface Lifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface Lifecycle
    • handleMessageInternal

      protected void handleMessageInternal(Message<?> message)
      Specified by:
      handleMessageInternal in class org.springframework.integration.handler.AbstractMessageHandler