jackdaw

https://github.com/FundingCircle/jackdaw
lxsli 2019-10-01T13:19:24.044300Z

Hello again... I'm trying to mix the streams + processor APIs. Specifically I want to add a Processor to the end of my topology which sends messages to multiple topics. The issue I'm hitting is that Streams (/Jackdaw) gives my processor a random name, so I have no easy way to call Topology.addSink(String processor-name, ...).

lxsli 2019-10-01T13:20:09.045100Z

I'd prefer to avoid introspecting the topology to dig out that name, I can't see a way to do that robustly

2019-10-01T13:23:31.049500Z

Are you using the Processor because you need some other feature not provided by the DSL? I think you can achieve what you've described with something like this...

(fn [builder]
  (let [foo (k/stream builder foo-topic)]
     (-> foo (k/map identity) (k/to foo-1))
     (-> foo (k/map identity) (k/to foo-2))
     (-> foo (k/map identity) (k/to foo-3))
     builder))

lxsli 2019-10-01T13:23:54.049700Z

This is related to a wider concern that if 1 message (a command) is broken up into many events and those events are committed separately, that a command may get partially executed in case of downtime. Otherwise I could branch.

2019-10-01T13:25:07.050200Z

Ah ok. So you want to have control over when the commit happens. :thinking_face:

lxsli 2019-10-01T13:25:12.050400Z

Yep exactly

lxsli 2019-10-01T13:25:44.051Z

(defn dispatch-processor
  "Why not `flat-map f` beforehand instead of passing it in here? That would
  split one message into many and therefore commit many times instead of once."
  [f ctx k v]
  (doseq [[topic msg-key msg] (f [k v])]
    (.forward ctx msg-key msg (To/child topic)))
  (.commit ctx))

lxsli 2019-10-01T13:25:56.051200Z

that's what I'm trying to attach

lxsli 2019-10-01T13:26:18.051500Z

Open to better ways to achieve this