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,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.ChannelInterceptorListNested 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, metersFields 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.messaging.MessageChannel
INDEFINITE_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionPostgresSubscribableChannel(JdbcChannelMessageStore jdbcChannelMessageStore, Object groupId, PostgresChannelMessageTableSubscriber messageTableSubscriber) Create a subscribable channel for a Postgres database. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanSubclasses must implement this method.protected MessageDispatcherReturn the group id for which this subscription receives notifications.Return the region for which this subscription receives notifications.voidIndicate that a message was added to the represented region and group id.protected voidonInit()Subclasses may implement this for initialization logic.voidsetDispatcherExecutor(Executor executor) Set the executor to use for dispatching newly received messages.voidsetErrorHandler(ErrorHandler errorHandler) Set aErrorHandlerfor messages which cannot be dispatched by this channel.voidsetRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate) Set the retry template to use for retries in case of exception in downstream processingvoidsetTransactionManager(PlatformTransactionManager transactionManager) Set the transaction manager to use for message processing.booleansubscribe(MessageHandler handler) booleanunsubscribe(MessageHandler handle) Methods inherited from class org.springframework.integration.channel.AbstractSubscribableChannel
getSubscriberCountMethods 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, setShouldTrackMethods 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, 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
getManagedName, getManagedType, getThisAs, setManagedName, setManagedTypeMethods inherited from interface org.springframework.messaging.MessageChannel
send, sendMethods 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:
-
setErrorHandler
Set aErrorHandlerfor messages which cannot be dispatched by this channel. Used as a recovery callback afterRetryTemplateexecution throws an exception.- Parameters:
errorHandler- theErrorHandlerto use.- Since:
- 6.0.9
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classAbstractMessageChannel
-
subscribe
- Specified by:
subscribein interfaceSubscribableChannel- Overrides:
subscribein classAbstractSubscribableChannel
-
unsubscribe
- Specified by:
unsubscribein interfaceSubscribableChannel- Overrides:
unsubscribein classAbstractSubscribableChannel
-
getDispatcher
- Specified by:
getDispatcherin classAbstractSubscribableChannel
-
doSend
Description copied from class:AbstractMessageChannelSubclasses 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:
doSendin classAbstractSubscribableChannel- Parameters:
message- The message.timeout- The timeout.- Returns:
- true if the
sendwas successful.
-
notifyUpdate
public void notifyUpdate()Description copied from interface:PostgresChannelMessageTableSubscriber.SubscriptionIndicate 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:
notifyUpdatein interfacePostgresChannelMessageTableSubscriber.Subscription
-
getRegion
Description copied from interface:PostgresChannelMessageTableSubscriber.SubscriptionReturn the region for which this subscription receives notifications.- Specified by:
getRegionin interfacePostgresChannelMessageTableSubscriber.Subscription- Returns:
- The relevant region of the
JdbcChannelMessageStore.
-
getGroupId
Description copied from interface:PostgresChannelMessageTableSubscriber.SubscriptionReturn the group id for which this subscription receives notifications.- Specified by:
getGroupIdin interfacePostgresChannelMessageTableSubscriber.Subscription- Returns:
- The group id of the
PostgresSubscribableChannel.
-