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 ofListenNotify.listen(Jdbi, String, Duration)that allows you to listen for notifications from multiple tables using a single polling thread
-
-
Constructor Summary
Constructors Constructor Description MultiTableChangeListener(org.jdbi.v3.core.Jdbi jdbi, Duration pollingInterval, com.fasterxml.jackson.databind.ObjectMapper objectMapper, EventBus eventBus)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()EventBusgetEventBus()MultiTableChangeListenerlistenToNotificationsFor(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 methodMultiTableChangeListenerunlistenToNotificationsFor(String tableName)Stop listening for notifications related to changes to the given table
-
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getEventBus
public 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
public MultiTableChangeListener unlistenToNotificationsFor(String tableName)
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
-
-