Class EventHubsInboundChannelAdapter

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
com.azure.spring.integration.eventhubs.inbound.EventHubsInboundChannelAdapter
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.beans.factory.SmartInitializingSingleton, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.core.MessageProducer, 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

public class EventHubsInboundChannelAdapter extends org.springframework.integration.endpoint.MessageProducerSupport
Message driven inbound channel adapter for Azure Event Hubs.

Example:

 
   @ServiceActivator(inputChannel = "input")
     public void messageReceiver(byte[] payload, @Header(AzureHeaders.CHECKPOINTER) Checkpointer checkpointer) {
         String message = new String(payload);
         LOGGER.info("New message received: '{}'", message);
         checkpointer.success()
                 .doOnSuccess(s -> LOGGER.info("Message '{}' successfully checkpointed", message))
                 .doOnError(e -> LOGGER.error("Error found", e))
                 .block();
     }

    @Bean
     public EventHubsInboundChannelAdapter messageChannelAdapter(
         @Qualifier("input") MessageChannel inputChannel, EventHubsMessageListenerContainer container) {
         EventHubsInboundChannelAdapter adapter =
             new EventHubsInboundChannelAdapter(container);
         adapter.setOutputChannel(inputChannel);
         return adapter;
     }

    @Bean
     public EventHubsMessageListenerContainer listener(
     EventHubsProcessorFactory processorFactory) {
         EventHubsContainerProperties containerProperties = new EventHubsContainerProperties();
         containerProperties.setEventHubName("eventhub-1");
         containerProperties.setConsumerGroup("consumer-group-1");
         containerProperties.setCheckpointConfig(new CheckpointConfig(CheckpointMode.MANUAL));
         return new EventHubsMessageListenerContainer(processorFactory, containerProperties);
     }

    @Bean
     public MessageChannel input() {
         return new DirectChannel();
     }
  
  • 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.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
    Construct a EventHubsInboundChannelAdapter with the specified EventHubsMessageListenerContainer, event Hub Name, consumer Group and CheckpointConfig.
    EventHubsInboundChannelAdapter(EventHubsMessageListenerContainer listenerContainer, com.azure.spring.messaging.ListenerMode listenerMode)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected void
     
    protected void
     
    void
    setBatchMessageConverter(com.azure.spring.messaging.converter.AzureMessageConverter<com.azure.messaging.eventhubs.models.EventBatchContext,com.azure.messaging.eventhubs.EventData> messageConverter)
    Set message converter.
    void
    setInstrumentationId(String instrumentationId)
    Set instrumentation id.
    void
    Set instrumentation Manager.
    void
    setMessageConverter(com.azure.spring.messaging.converter.AzureMessageConverter<com.azure.messaging.eventhubs.EventData,com.azure.messaging.eventhubs.EventData> messageConverter)
    Set message converter.
    void
    setPayloadType(Class<?> payloadType)
    Set payload Type.

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

    afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisher

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

    destroy, 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, getComponentType, 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

    destroy, getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedType

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

    getBeanName, getComponentName, getComponentType
  • Constructor Details

  • Method Details

    • onInit

      protected void onInit()
      Overrides:
      onInit in class org.springframework.integration.endpoint.MessageProducerSupport
    • doStart

      public void doStart()
      Overrides:
      doStart in class org.springframework.integration.endpoint.MessageProducerSupport
    • doStop

      protected void doStop()
      Overrides:
      doStop in class org.springframework.integration.endpoint.MessageProducerSupport
    • setMessageConverter

      public void setMessageConverter(com.azure.spring.messaging.converter.AzureMessageConverter<com.azure.messaging.eventhubs.EventData,com.azure.messaging.eventhubs.EventData> messageConverter)
      Set message converter.
      Parameters:
      messageConverter - the message converter
    • setBatchMessageConverter

      public void setBatchMessageConverter(com.azure.spring.messaging.converter.AzureMessageConverter<com.azure.messaging.eventhubs.models.EventBatchContext,com.azure.messaging.eventhubs.EventData> messageConverter)
      Set message converter.
      Parameters:
      messageConverter - the message converter
    • setPayloadType

      public void setPayloadType(Class<?> payloadType)
      Set payload Type.
      Parameters:
      payloadType - the payload Type
    • setInstrumentationManager

      public void setInstrumentationManager(InstrumentationManager instrumentationManager)
      Set instrumentation Manager.
      Parameters:
      instrumentationManager - the instrumentation Manager
    • setInstrumentationId

      public void setInstrumentationId(String instrumentationId)
      Set instrumentation id.
      Parameters:
      instrumentationId - the instrumentation id