Class PostgresChannelMessageTableSubscriber
java.lang.Object
org.springframework.integration.jdbc.channel.PostgresChannelMessageTableSubscriber
- All Implemented Interfaces:
- Lifecycle,- Phased,- SmartLifecycle
A subscriber for new messages being received by a Postgres database via a
 
JdbcChannelMessageStore. This subscriber implementation is using
 Postgres' LISTEN/NOTIFY mechanism to allow for receiving push
 notifications for new messages what functions even if a message is written
 and read from different JVMs or JdbcChannelMessageStores.
 
 Note that this subscriber requires an unshared PgConnection which
 remains open for any lifecycle. It is therefore recommended to execute a single
 subscriber for any JVM. For this reason, this subscriber is region-agnostic.
 To listen for messages for a given region and group id, use a
 PostgresChannelMessageTableSubscriber.Subscription and register it with this subscriber.
 
 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, Christian Tzolov, Johannes Edmeier
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceA subscription to aPostgresChannelMessageTableSubscriberfor receiving push notifications for new messages that are added to aJdbcChannelMessageStore.
- 
Field SummaryFields inherited from interface org.springframework.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionPostgresChannelMessageTableSubscriber(PgConnectionSupplier connectionSupplier) Create a new subscriber using theJdbcChannelMessageStore.DEFAULT_TABLE_PREFIX.PostgresChannelMessageTableSubscriber(PgConnectionSupplier connectionSupplier, String tablePrefix) Create a new subscriber.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanvoidsetNotificationTimeout(Duration notificationTimeout) Set the timeout for the notification polling.voidsetTaskExecutor(AsyncTaskExecutor taskExecutor) Provide a managedAsyncTaskExecutorfor Postgres listener daemon.voidstart()voidstop()booleansubscribe(PostgresChannelMessageTableSubscriber.Subscription subscription) Add a new subscription to this subscriber.booleanRemove a previous subscription from this subscriber.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecyclegetPhase, isAutoStartup, stop
- 
Constructor Details- 
PostgresChannelMessageTableSubscriberCreate a new subscriber using theJdbcChannelMessageStore.DEFAULT_TABLE_PREFIX.- Parameters:
- connectionSupplier- The connection supplier for the targeted Postgres database.
 
- 
PostgresChannelMessageTableSubscriberpublic PostgresChannelMessageTableSubscriber(PgConnectionSupplier connectionSupplier, String tablePrefix) Create a new subscriber.- Parameters:
- connectionSupplier- The connection supplier for the targeted Postgres database.
- tablePrefix- The table prefix of the- JdbcChannelMessageStoreto subscribe to.
 
 
- 
- 
Method Details- 
setTaskExecutorProvide a managedAsyncTaskExecutorfor Postgres listener daemon.- Parameters:
- taskExecutor- the- AsyncTaskExecutorto use.
- Since:
- 6.2
 
- 
setNotificationTimeoutSet the timeout for the notification polling. If for the specified duration no notificiation are received the underlying connection is closed and re-established. Setting a value ofDuration.ZEROwill disable the timeout and wait forever. This might cause problems in DB failover scenarios.- Parameters:
- notificationTimeout- the timeout for the notification polling.
- Since:
- 6.1.8
 
- 
subscribeAdd a new subscription to this subscriber.- Parameters:
- subscription- The subscription to register.
- Returns:
- trueif the subscription was not already added.
 
- 
unsubscribeRemove a previous subscription from this subscriber.- Parameters:
- subscription- The subscription to remove.
- Returns:
- trueif the subscription was previously registered and is now removed.
 
- 
start
- 
stop
- 
isRunning
 
-