Class MultiTableChangeListener<T extends TableChangeNotification>
java.lang.Object
dk.cloudcreate.essentials.components.foundation.postgresql.MultiTableChangeListener<T>
- All Implemented Interfaces:
Closeable,AutoCloseable
public class MultiTableChangeListener<T extends TableChangeNotification>
extends Object
implements Closeable
Variant of
ListenNotify.listen(Jdbi, String, Duration) that allows you to listen for notifications from multiple tables using a single polling thread-
Constructor Summary
ConstructorsConstructorDescriptionMultiTableChangeListener(org.jdbi.v3.core.Jdbi jdbi, Duration pollingInterval, com.fasterxml.jackson.databind.ObjectMapper objectMapper, dk.cloudcreate.essentials.reactive.EventBus eventBus) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()dk.cloudcreate.essentials.reactive.EventBuslistenToNotificationsFor(String tableName, Class<? extends T> tableNotificationType) Start listening for notifications related to changes to the given table
Note: Remember to install the notification support, usingListenNotify.addChangeNotificationTriggerToTable(Handle, String, List, String...), prior to using this methodunlistenToNotificationsFor(String tableName) Stop listening for notifications related to changes to the given table
-
Constructor Details
-
MultiTableChangeListener
public MultiTableChangeListener(org.jdbi.v3.core.Jdbi jdbi, Duration pollingInterval, com.fasterxml.jackson.databind.ObjectMapper objectMapper, dk.cloudcreate.essentials.reactive.EventBus eventBus)
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getEventBus
public dk.cloudcreate.essentials.reactive.EventBus getEventBus() -
listenToNotificationsFor
public MultiTableChangeListener listenToNotificationsFor(String tableName, Class<? extends T> tableNotificationType) Start listening for notifications related to changes to the given table
Note: Remember to install the notification support, usingListenNotify.addChangeNotificationTriggerToTable(Handle, String, List, String...), prior to using this method- Parameters:
tableName- the name of the table to listen toTableChangeNotification'stableNotificationType- the concrete type ofTableChangeNotificationthat eachListenNotify.SqlOperationrelated change will result in- Returns:
- this listener instance
-
unlistenToNotificationsFor
Stop listening for notifications related to changes to the given table- Parameters:
tableName- the name of the table to stop listen forTableChangeNotification's to- Returns:
- this listener instance
-