Class ServiceBusInboundChannelAdapter
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
com.azure.spring.integration.servicebus.inbound.ServiceBusInboundChannelAdapter
- 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 ServiceBusInboundChannelAdapter
extends org.springframework.integration.endpoint.MessageProducerSupport
Inbound channel adapter for Service Bus.
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 ServiceBusInboundChannelAdapter queueMessageChannelAdapter(
@Qualifier("input") MessageChannel inputChannel,
ServiceBusMessageListenerContainer container) {
ServiceBusInboundChannelAdapter adapter =
new ServiceBusInboundChannelAdapter(container);
adapter.setOutputChannel(inputChannel);
return adapter;
}
@Bean
public ServiceBusMessageListenerContainer container(
ServiceBusProcessorFactory processorFactory) {
ServiceBusContainerProperties containerProperties = new ServiceBusContainerProperties();
containerProperties.setEntityName("RECEIVE_QUEUE_NAME");
containerProperties.setAutoComplete(false);
return new ServiceBusMessageListenerContainer(processorFactory, containerProperties);
}
@Bean(name = INPUT_CHANNEL)
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, 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
ConstructorsConstructorDescriptionServiceBusInboundChannelAdapter(ServiceBusMessageListenerContainer listenerContainer) Construct aServiceBusInboundChannelAdapterwith the specifiedServiceBusMessageListenerContainer.ServiceBusInboundChannelAdapter(ServiceBusMessageListenerContainer listenerContainer, com.azure.spring.messaging.ListenerMode listenerMode) Construct aServiceBusInboundChannelAdapterwith the specifiedServiceBusMessageListenerContainer,ListenerMode. -
Method Summary
Modifier and TypeMethodDescriptionvoiddoStart()protected voidonInit()voidsetInstrumentationId(String instrumentationId) Set instrumentation id.voidsetInstrumentationManager(InstrumentationManager instrumentationManager) Set instrumentation manager.voidsetMessageConverter(com.azure.spring.messaging.converter.AzureMessageConverter<com.azure.messaging.servicebus.ServiceBusReceivedMessage, com.azure.messaging.servicebus.ServiceBusMessage> messageConverter) Set message converter.voidsetPayloadType(Class<?> payloadType) Set payload type.Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
afterSingletonsInstantiated, buildErrorMessage, doStop, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, 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
-
ServiceBusInboundChannelAdapter
Construct aServiceBusInboundChannelAdapterwith the specifiedServiceBusMessageListenerContainer.- Parameters:
listenerContainer- the message listener container.
-
ServiceBusInboundChannelAdapter
public ServiceBusInboundChannelAdapter(ServiceBusMessageListenerContainer listenerContainer, com.azure.spring.messaging.ListenerMode listenerMode) Construct aServiceBusInboundChannelAdapterwith the specifiedServiceBusMessageListenerContainer,ListenerMode.- Parameters:
listenerContainer- the message listener container.listenerMode- the listen 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
-
setMessageConverter
public void setMessageConverter(com.azure.spring.messaging.converter.AzureMessageConverter<com.azure.messaging.servicebus.ServiceBusReceivedMessage, com.azure.messaging.servicebus.ServiceBusMessage> 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
-