Skip to content

Commit

Permalink
[Harshal|Shubhang] Add function for deleting RMQ dead-letter messages
Browse files Browse the repository at this point in the history
  • Loading branch information
harshalbhatia committed Mar 24, 2022
1 parent a04fbad commit 26f9ec3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ziggurat/messaging/consumer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@
(when (some? payload)
(process-message-from-queue ch meta payload topic-entity processing-fn))))))))


(defn delete-dead-set-messages
"This method deletes `count` number of messages from RabbitMQ dead-letter queue for topic `topic-entity` and channel
`channel`."
[topic-entity channel count]
(with-open [ch (lch/open connection)]
(let [queue-name (construct-queue-name topic-entity channel)]
(doall (for [_ (range count)]
(lb/get ch queue-name true))))))

(defn- message-handler [wrapped-mapper-fn topic-entity]
(fn [ch meta ^bytes payload]
(clog/with-logging-context {:consumer-group topic-entity} (process-message-from-queue ch meta payload topic-entity wrapped-mapper-fn))))
Expand Down

0 comments on commit 26f9ec3

Please sign in to comment.