clj-commons / manifold

A compatibility layer for event-driven abstractions
1.02k stars 106 forks source link

How does one specify the thread in which consume runs? #180

Closed pdenno closed 5 years ago

pdenno commented 5 years ago

Hi,

Thank you for this wonderful library!

I have a web socket bus/publish! messages to an event bus using s/consume, and a bus/subscribe stream that will pick up them up. This latter stream also uses s/consume and its callback will d/success! a deferred, dee, when it sees what it is looking for.

(-> (d/chain dee (fn [d] (log/info "Waiting on" d) d)) (d/timeout! 5000) (deref))

The problem is that the deref here will pause the s/consume on the event bus, so the subscriber stream doesn't see any new messages. What I want, I think, is to provide a thread for the s/consume that is listening on the web socket and publishing to the event bus. But I don't see how to do it. Just wrapping the s/consume in a d/future doesn't help.

pdenno commented 5 years ago

I don't know whether what I wrote above, the need to specify a thread for s/consume, is an issue or not, but I've found that that wasn't the problem in this case. The problem was that under certain circumstances the server with the websocket was suspending transmission.