A LISTEN/NOTIFY connection that can be shared by many consumers.
Every topic's trigger NOTIFYs on one channel, ottla, with the payload
<topic>:<eid>, so a listener LISTENs once per connection and routes
notifications to its subscribers by topic. Subscribing and
unsubscribing never touch the connection.
The listener runs a single long-lived loop task on an ExecutorService (by default one of its own, with a single thread). The loop owns the connection, so the connection is never used concurrently. Each pass dispatches any pending notifications.
A LISTEN/NOTIFY connection that can be shared by many consumers. Every topic's trigger NOTIFYs on one channel, `ottla`, with the payload `<topic>:<eid>`, so a listener LISTENs once per connection and routes notifications to its subscribers by topic. Subscribing and unsubscribing never touch the connection. The listener runs a single long-lived loop task on an ExecutorService (by default one of its own, with a single thread). The loop owns the connection, so the connection is never used concurrently. Each pass dispatches any pending notifications.
(subscribe listener topic wake-fn)Call (wake-fn eid) for each notification of new records on topic,
where eid is the highest eid appended (nil if the payload has none).
(wake-fn nil) is also called whenever the listener starts listening
(initially and after a reconnect), and on subscribing if it already
is, since notifications sent before then are lost to the subscriber.
Returns a Subscription: close it to unsubscribe, and see its
status for whether the listener is currently listening.
Call `(wake-fn eid)` for each notification of new records on `topic`, where eid is the highest eid appended (nil if the payload has none). `(wake-fn nil)` is also called whenever the listener starts listening (initially and after a reconnect), and on subscribing if it already is, since notifications sent before then are lost to the subscriber. Returns a `Subscription`: close it to unsubscribe, and see its `status` for whether the listener is currently listening.
(start-listener {:keys [conn-map]}
{:keys [executor listen-min-ms listen-max-ms reconnect-ms
exception-handler thread-name await-close-ms]
listen-conn-map :conn-map
:or {listen-min-ms 10
listen-max-ms 250
reconnect-ms 2000
await-close-ms 1000
exception-handler default-exception-handler
thread-name "ottla-listener"}})Start a listener. See ottla.core/start-listener.
:thread-name (undocumented) names the thread of a listener-owned
executor.
Start a listener. See `ottla.core/start-listener`. `:thread-name` (undocumented) names the thread of a listener-owned executor.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |