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.ComponentSourceAware,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
lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionEventHubsInboundChannelAdapter(EventHubsMessageListenerContainer listenerContainer) Construct aEventHubsInboundChannelAdapterwith the specifiedEventHubsMessageListenerContainer, event Hub Name, consumer Group andCheckpointConfig.EventHubsInboundChannelAdapter(EventHubsMessageListenerContainer listenerContainer, com.azure.spring.messaging.ListenerMode listenerMode) Construct aEventHubsInboundChannelAdapterwith the specifiedEventHubsMessageListenerContainer,ListenerModeandCheckpointConfig. -
Method Summary
Modifier and TypeMethodDescriptionvoiddoStart()protected voiddoStop()protected voidonInit()voidsetBatchMessageConverter(com.azure.spring.messaging.converter.AzureMessageConverter<com.azure.messaging.eventhubs.models.EventBatchContext, com.azure.messaging.eventhubs.EventData> messageConverter) Set message converter.voidsetInstrumentationId(String instrumentationId) Set instrumentation id.voidsetInstrumentationManager(InstrumentationManager instrumentationManager) Set instrumentation Manager.voidsetMessageConverter(com.azure.spring.messaging.converter.AzureMessageConverter<com.azure.messaging.eventhubs.EventData, com.azure.messaging.eventhubs.EventData> messageConverter) Set message converter.voidsetPayloadType(Class<?> payloadType) Set payload Type.Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, getRequiredOutputChannel, isObserved, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisherMethods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
destroy, doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getComponentType, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
destroy, getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName, getComponentType
-
Constructor Details
-
EventHubsInboundChannelAdapter
Construct aEventHubsInboundChannelAdapterwith the specifiedEventHubsMessageListenerContainer, event Hub Name, consumer Group andCheckpointConfig.- Parameters:
listenerContainer- the processor container
-
EventHubsInboundChannelAdapter
public EventHubsInboundChannelAdapter(EventHubsMessageListenerContainer listenerContainer, com.azure.spring.messaging.ListenerMode listenerMode) Construct aEventHubsInboundChannelAdapterwith the specifiedEventHubsMessageListenerContainer,ListenerModeandCheckpointConfig.- Parameters:
listenerContainer- the event processors containerlistenerMode- the listener mode
-
-
Method Details
-
onInit
protected void onInit()- Overrides:
onInitin classorg.springframework.integration.endpoint.MessageProducerSupport
-
doStart
public void doStart()- Overrides:
doStartin classorg.springframework.integration.endpoint.MessageProducerSupport
-
doStop
protected void doStop()- Overrides:
doStopin classorg.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
Set payload Type.- Parameters:
payloadType- the payload Type
-
setInstrumentationManager
Set instrumentation Manager.- Parameters:
instrumentationManager- the instrumentation Manager
-
setInstrumentationId
Set instrumentation id.- Parameters:
instrumentationId- the instrumentation id
-