Class SubscribableRedisChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.redis.channel.SubscribableRedisChannel
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Lifecycle
,Phased
,SmartLifecycle
,BroadcastCapableChannel
,ExpressionCapable
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
,MessageChannel
,SubscribableChannel
,InterceptableChannel
public class SubscribableRedisChannel
extends AbstractMessageChannel
implements BroadcastCapableChannel, ManageableSmartLifecycle
An
AbstractMessageChannel
implementation with BroadcastCapableChannel
aspect to provide a pub-sub semantics to consume messages fgrom Redis topic.- Since:
- 2.0
- Author:
- Oleg Zhurakousky, Gary Russell, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannel
AbstractMessageChannel.ChannelInterceptorList
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.channel.AbstractMessageChannel
interceptors, meters
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.messaging.MessageChannel
INDEFINITE_TIMEOUT
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionSubscribableRedisChannel
(RedisConnectionFactory connectionFactory, String topicName) -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
protected boolean
Subclasses must implement this method.int
getPhase()
boolean
boolean
void
onInit()
Subclasses may implement this for initialization logic.void
setMaxSubscribers
(int maxSubscribers) Specify the maximum number of subscribers supported by the channel's dispatcher.void
setMessageConverter
(MessageConverter messageConverter) Specify theMessageConverter
to use when trying to convert to one of this channel's supported datatypes (in order) for a Message whose payload does not already match.void
setSerializer
(RedisSerializer<?> serializer) void
setTaskExecutor
(Executor taskExecutor) void
start()
void
stop()
void
boolean
subscribe
(MessageHandler handler) boolean
unsubscribe
(MessageHandler handler) Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
addInterceptor, addInterceptor, getComponentType, getFullChannelName, getIChannelInterceptorList, getIntegrationPatternType, getInterceptors, getMetricsCaptor, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, removeInterceptor, removeInterceptor, send, send, setDatatypes, setInterceptors, setLoggingEnabled, setObservationConvention, setShouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, 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.channel.BroadcastCapableChannel
isBroadcast
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getManagedName, getManagedType, getThisAs, setManagedName, setManagedType
Methods inherited from interface org.springframework.messaging.MessageChannel
send, send
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
SubscribableRedisChannel
-
-
Method Details
-
setTaskExecutor
-
setMessageConverter
Description copied from class:AbstractMessageChannel
Specify theMessageConverter
to use when trying to convert to one of this channel's supported datatypes (in order) for a Message whose payload does not already match.Note: only the
MessageConverter.fromMessage(Message, Class)
method is used. If the returned object is not aMessage
, the inbound headers will be copied; if the returned object is aMessage
, it is expected that the converter will have fully populated the headers; no further action is performed by the channel. Ifnull
is returned, conversion to the next datatype (if any) will be attempted. Defaults to aDefaultDatatypeChannelMessageConverter
.- Overrides:
setMessageConverter
in classAbstractMessageChannel
- Parameters:
messageConverter
- The message converter.
-
setSerializer
-
setMaxSubscribers
public void setMaxSubscribers(int maxSubscribers) Specify the maximum number of subscribers supported by the channel's dispatcher.- Parameters:
maxSubscribers
- The maximum number of subscribers allowed.
-
subscribe
- Specified by:
subscribe
in interfaceSubscribableChannel
-
unsubscribe
- Specified by:
unsubscribe
in interfaceSubscribableChannel
-
doSend
Description copied from class:AbstractMessageChannel
Subclasses must implement this method. A non-negative timeout indicates how long to wait if the channel is at capacity (if the value is 0, it must return immediately with or without success). A negative timeout value indicates that the method should block until either the message is accepted or the blocking thread is interrupted.- Specified by:
doSend
in classAbstractMessageChannel
- Parameters:
message
- The message.arg1
- The timeout.- Returns:
- true if the
send
was successful.
-
onInit
public void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classAbstractMessageChannel
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartup
in interfaceSmartLifecycle
-
getPhase
public int getPhase()- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceLifecycle
- Specified by:
isRunning
in interfaceManageableLifecycle
-
start
public void start()- Specified by:
start
in interfaceLifecycle
- Specified by:
start
in interfaceManageableLifecycle
-
stop
public void stop()- Specified by:
stop
in interfaceLifecycle
- Specified by:
stop
in interfaceManageableLifecycle
-
stop
- Specified by:
stop
in interfaceSmartLifecycle
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDisposableBean
- Specified by:
destroy
in interfaceIntegrationManagement
- Overrides:
destroy
in classAbstractMessageChannel
-