Class PostgresSubscribableChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.channel.AbstractSubscribableChannel
org.springframework.integration.jdbc.channel.PostgresSubscribableChannel
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,ComponentSourceAware
,ExpressionCapable
,IntegrationPattern
,PostgresChannelMessageTableSubscriber.Subscription
,NamedComponent
,IntegrationManagement
,SubscribableChannelManagement
,TrackableComponent
,MessageChannel
,SubscribableChannel
,InterceptableChannel
public class PostgresSubscribableChannel
extends AbstractSubscribableChannel
implements PostgresChannelMessageTableSubscriber.Subscription
An
AbstractSubscribableChannel
for receiving push notifications for
messages send to a group id of a JdbcChannelMessageStore
. Receiving
such push notifications is only possible if using a Postgres database.
In order to function, the Postgres database that is used must define a trigger
for sending notifications upon newly arrived messages. This trigger is defined
in the schema-postgresql.sql file within this artifact but commented
out.- Since:
- 6.0
- Author:
- Rafael Winterhalter, Artem Bilan, Igor Lovich
-
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
-
Constructor Summary
ConstructorDescriptionPostgresSubscribableChannel
(JdbcChannelMessageStore jdbcChannelMessageStore, Object groupId, PostgresChannelMessageTableSubscriber messageTableSubscriber) Create a subscribable channel for a Postgres database. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Subclasses must implement this method.protected MessageDispatcher
Return the group id for which this subscription receives notifications.Return the region for which this subscription receives notifications.void
Indicate that a message was added to the represented region and group id.protected void
onInit()
Subclasses may implement this for initialization logic.void
setDispatcherExecutor
(Executor executor) Set the executor to use for dispatching newly received messages.void
setErrorHandler
(ErrorHandler errorHandler) Set aErrorHandler
for messages which cannot be dispatched by this channel.void
setRetryTemplate
(org.springframework.retry.support.RetryTemplate retryTemplate) Set the retry template to use for retries in case of exception in downstream processingvoid
setTransactionManager
(PlatformTransactionManager transactionManager) Set the transaction manager to use for message processing.boolean
subscribe
(MessageHandler handler) boolean
unsubscribe
(MessageHandler handle) Methods inherited from class org.springframework.integration.channel.AbstractSubscribableChannel
getSubscriberCount
Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
addInterceptor, addInterceptor, destroy, getComponentType, getFullChannelName, getIChannelInterceptorList, getIntegrationPatternType, getInterceptors, getMetricsCaptor, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, removeInterceptor, removeInterceptor, send, send, setDatatypes, setInterceptors, setLoggingEnabled, setMessageConverter, setObservationConvention, setShouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, 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
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
-
PostgresSubscribableChannel
public PostgresSubscribableChannel(JdbcChannelMessageStore jdbcChannelMessageStore, Object groupId, PostgresChannelMessageTableSubscriber messageTableSubscriber) Create a subscribable channel for a Postgres database.- Parameters:
jdbcChannelMessageStore
- The message store to use for the relevant region.groupId
- The group id that is targeted by the subscription.messageTableSubscriber
- The subscriber to use for receiving notifications.
-
-
Method Details
-
setDispatcherExecutor
Set the executor to use for dispatching newly received messages.- Parameters:
executor
- The executor to use.
-
setTransactionManager
Set the transaction manager to use for message processing. Each message will be processed in a separate transaction- Parameters:
transactionManager
- The transaction manager to use- Since:
- 6.0.5
- See Also:
-
setRetryTemplate
public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate) Set the retry template to use for retries in case of exception in downstream processing- Parameters:
retryTemplate
- The retry template to use- Since:
- 6.0.5
- See Also:
-
RetryTemplate
-
setErrorHandler
Set aErrorHandler
for messages which cannot be dispatched by this channel. Used as a recovery callback afterRetryTemplate
execution throws an exception.- Parameters:
errorHandler
- theErrorHandler
to use.- Since:
- 6.0.9
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classAbstractMessageChannel
-
subscribe
- Specified by:
subscribe
in interfaceSubscribableChannel
- Overrides:
subscribe
in classAbstractSubscribableChannel
-
unsubscribe
- Specified by:
unsubscribe
in interfaceSubscribableChannel
- Overrides:
unsubscribe
in classAbstractSubscribableChannel
-
getDispatcher
- Specified by:
getDispatcher
in classAbstractSubscribableChannel
-
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.- Overrides:
doSend
in classAbstractSubscribableChannel
- Parameters:
message
- The message.timeout
- The timeout.- Returns:
- true if the
send
was successful.
-
notifyUpdate
public void notifyUpdate()Description copied from interface:PostgresChannelMessageTableSubscriber.Subscription
Indicate that a message was added to the represented region and group id. Note that this method might also be invoked if there are no new messages to read, for example if another subscription already read those messages or if a new messages might have arrived during a temporary connection loss.- Specified by:
notifyUpdate
in interfacePostgresChannelMessageTableSubscriber.Subscription
-
getRegion
Description copied from interface:PostgresChannelMessageTableSubscriber.Subscription
Return the region for which this subscription receives notifications.- Specified by:
getRegion
in interfacePostgresChannelMessageTableSubscriber.Subscription
- Returns:
- The relevant region of the
JdbcChannelMessageStore
.
-
getGroupId
Description copied from interface:PostgresChannelMessageTableSubscriber.Subscription
Return the group id for which this subscription receives notifications.- Specified by:
getGroupId
in interfacePostgresChannelMessageTableSubscriber.Subscription
- Returns:
- The group id of the
PostgresSubscribableChannel
.
-