jackdaw

https://github.com/FundingCircle/jackdaw
finchharold 2021-05-02T02:07:35.116300Z

I set this to seek-to-beginning-eager, and still it's returning count=0.

2021-05-02T02:08:17.116900Z

and you know there are messages in that topic?

finchharold 2021-05-02T02:09:19.117500Z

Yeah, just now I ran this command, bin/kafka-console-consumer.sh --topic app.public.chatrooms --from-beginning --bootstrap-server http://localhost:9092/

finchharold 2021-05-02T02:09:48.118500Z

It should all the messages from beginning and even showed whenever I update the chatroom data...

finchharold 2021-05-02T02:10:04.118900Z

showed*

2021-05-02T02:10:32.119700Z

And you set consumer-config and topic-serde ?

finchharold 2021-05-02T02:11:42.120800Z

So, the consumer is already set and is subscribed to the topic...

finchharold 2021-05-02T02:18:09.122200Z

Wait wait

finchharold 2021-05-02T02:18:21.122500Z

@dcj Now it is returning this poll returned, count: 19 poll returned, count: 0 poll returned, count: 0 poll returned, count: 0 poll returned, count: 0

2021-05-02T02:18:33.122800Z

19 is good

2021-05-02T02:18:48.123100Z

you got 19

finchharold 2021-05-02T02:19:49.123900Z

Yeah so now how can I get just the latest message? like if I changed something now, then it should return only that... is that possible?

2021-05-02T02:20:18.124300Z

seek to end eager

2021-05-02T02:20:43.125100Z

then publish more msgs to topic

finchharold 2021-05-02T02:21:18.125300Z

Here, I'm running the prt-msgs-now function and it's returning only the count....?

finchharold 2021-05-02T02:22:37.126400Z

It should return the message too right, along with the count?

2021-05-02T02:22:58.127100Z

the poll msg is in 1 thread what r u doing when you read the msgs out of the channel?

2021-05-02T02:23:35.127900Z

in the dosync u should print value

finchharold 2021-05-02T02:25:02.128400Z

Yeah, I mean I did it like this

(defn prt-msgs-now
  [{consumer :com.app.graphql.kafka/consumer}]
  (let [msgs-chan   (chan)
        consumer-thread (thread (consume-adsb-msgs msgs-chan consumer))]
    (while true
      (let [adsb-messages (<!! msgs-chan)]
        (doseq [{:keys [key value partition timestamp offset] :as message} adsb-messages]
          (println value))))))

finchharold 2021-05-02T02:26:22.129Z

It is showing the message, thank you so much @dcj.

finchharold 2021-05-02T02:26:27.129200Z

Just one query though

finchharold 2021-05-02T02:26:53.129600Z

I tried it this way

(defn poll-kafka
  [{consumer :com.app.graphql.kafka/consumer}]
  (doseq [{:keys [value]} (jc/poll consumer 100)]
    (prn "Got record from Kafka" value)
    )
  (.commitSync consumer))

finchharold 2021-05-02T02:27:00.129900Z

Why do you think this didn't work?

finchharold 2021-05-02T02:32:28.130200Z

Yeah got it, because I missed the seek?

finchharold 2021-05-02T02:33:06.130900Z

Thank you again @dcj

gklijs 2021-05-02T06:17:55.131Z

I don't really get why you would want to send the messages to a channel through. It's hard to get either at least once or are most once guarantees that way imho.

finchharold 2021-05-02T12:36:45.131300Z

I'm using it for graphql streamer

finchharold 2021-05-02T12:37:23.132100Z

Actually I'd like to know is there a way to let the streamer know that there's something new in the kafka topic?

finchharold 2021-05-02T12:45:43.132800Z

Can I do it like this...?

(with-open [consumer (jc/seek-to-end-eager consumer)]
      (while true
        (doseq [{:keys [value]} (jc/poll consumer 100)]
          (send any method here???))))
    (.commitSync consumer)

finchharold 2021-05-02T16:01:18.133100Z

Can't I pole multiple times? Like run the poll-methd multiple times?

gklijs 2021-05-02T18:06:27.133200Z

If you never commit, but not very efficient. I just check every message from Kafka if it should be send to one of the active subscriptions. https://github.com/gklijs/bkes-demo/blob/7d86b9b2ef2b014c0ef85b045de8559013d9e9ee/graphql-endpoint/src/nl/openweb/graphql_endpoint/transaction_service.clj#L42