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.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, 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
ConstructorDescriptionServiceBusInboundChannelAdapter
(ServiceBusMessageListenerContainer listenerContainer) Construct aServiceBusInboundChannelAdapter
with the specifiedServiceBusMessageListenerContainer
.ServiceBusInboundChannelAdapter
(ServiceBusMessageListenerContainer listenerContainer, com.azure.spring.messaging.ListenerMode listenerMode) Construct aServiceBusInboundChannelAdapter
with the specifiedServiceBusMessageListenerContainer
,ListenerMode
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
doStart()
protected void
onInit()
void
setInstrumentationId
(String instrumentationId) Set instrumentation id.void
setInstrumentationManager
(InstrumentationManager instrumentationManager) Set instrumentation manager.void
setMessageConverter
(com.azure.spring.messaging.converter.AzureMessageConverter<com.azure.messaging.servicebus.ServiceBusReceivedMessage, com.azure.messaging.servicebus.ServiceBusMessage> messageConverter) Set message converter.void
setPayloadType
(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, 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, 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
-
ServiceBusInboundChannelAdapter
Construct aServiceBusInboundChannelAdapter
with the specifiedServiceBusMessageListenerContainer
.- Parameters:
listenerContainer
- the message listener container.
-
ServiceBusInboundChannelAdapter
public ServiceBusInboundChannelAdapter(ServiceBusMessageListenerContainer listenerContainer, com.azure.spring.messaging.ListenerMode listenerMode) Construct aServiceBusInboundChannelAdapter
with the specifiedServiceBusMessageListenerContainer
,ListenerMode
.- Parameters:
listenerContainer
- the message listener container.listenerMode
- the listen mode
-
-
Method Details
-
onInit
protected void onInit()- Overrides:
onInit
in classorg.springframework.integration.endpoint.MessageProducerSupport
-
doStart
public void doStart()- Overrides:
doStart
in 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
-