Class ListenDispatcher
- All Implemented Interfaces:
AutoCloseable
conversation_signal_doorbell.
The LISTEN connection lives outside HikariCP because LISTEN state is connection-bound and cannot survive being
returned to a pool — see design §6.2. A second short-lived DataSource (typically the bus's signal pool) is
used for the row-fetch SELECTs so the dedicated LISTEN connection only ever blocks on
PGConnection.getNotifications().
Reconnect semantics (design §6.2 / §8 #2): on any SQLException the dispatcher closes the listen connection,
sleeps 500 ms, opens a new one, re-issues LISTEN, runs a backlog query starting at the highest id seen so
far, and resumes. No signal loss because the rows live in the table independent of NOTIFY delivery.
Backstop self-poll (design §4.2): every selfPollMillis ms the dispatcher re-runs the fetch query without
waiting for a doorbell, catching any rows that arrived while a NOTIFY was dropped (e.g. backend crash, network
blip).
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionListenDispatcher(String jdbcUrl, Properties connectionProps, DataSource fetchDataSource, ConversationSignalRowCodec codec) ListenDispatcher(String jdbcUrl, Properties connectionProps, DataSource fetchDataSource, ConversationSignalRowCodec codec, long pollMillis, long selfPollMillis, long reconnectBackoffMillis) -
Method Summary
-
Field Details
-
CHANNEL
- See Also:
-
-
Constructor Details
-
ListenDispatcher
public ListenDispatcher(String jdbcUrl, Properties connectionProps, DataSource fetchDataSource, ConversationSignalRowCodec codec) -
ListenDispatcher
public ListenDispatcher(String jdbcUrl, Properties connectionProps, DataSource fetchDataSource, ConversationSignalRowCodec codec, long pollMillis, long selfPollMillis, long reconnectBackoffMillis)
-
-
Method Details
-
start
public void start()Starts the listener thread. Idempotent. -
track
public void track(at.aimon.core.agent.conversation.ConversationId id, Consumer<at.aimon.session.web.spi.ConversationSignal> handler) -
untrack
public void untrack(at.aimon.core.agent.conversation.ConversationId id) -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-