<commit_before>(ns clojure-mailgun-server.message-queue.subscriber
  (:require [langohr.core :as rmq]
            [langohr.channel :as lch]
            [langohr.queue :as lq]
            [langohr.consumers :as lc]
            [clojure-mailgun-server.mailer.mailgun :as mailgun]
            [cheshire.core :as json]
            [clojure.walk :as walk]
            [clojure.java.io :as io]
            [langohr.basic :as lb])
  (:import [clojure_mailgun_server.mailer.mailgun EmailRequest]))

(def ^{:const true}
  default-exchange-name "")

(defn message-handler
  [ch {:keys [content-type delivery-tag type] :as meta} ^bytes payload]
  (let [msg (json/parse-stream (io/reader payload))
        msg# (walk/keywordize-keys msg)
        email-request (EmailRequest. (:to msg#) (:subject msg#) (:template msg#) (:values msg#))]
    (timbre/info "[Processing email for Subject through MQ" (:subject email-request) " to " (:to email-request)
    (mailgun/send-email email-request)))
(defn -main
  [& args]
  (let [conn (rmq/connect)
        ch (lch/open conn)
        qname "clojure-mailgun-server.message-queue"]
    (println (format "[main] subscriber Connected. Channel id: %d" (.getChannelNumber ch)))
    (lq/declare ch qname {:exclusive false :auto-delete true})
    (lc/subscribe ch qname message-handler {:auto-ack true}))))<commit_msg>Fixing brackets issues<commit_after>(ns clojure-mailgun-server.message-queue.subscriber
  (:require [langohr.core :as rmq]
            [langohr.channel :as lch]
            [langohr.queue :as lq]
            [langohr.consumers :as lc]
            [clojure-mailgun-server.mailer.mailgun :as mailgun]
            [cheshire.core :as json]
            [taoensso.timbre :as timbre]
            [clojure.walk :as walk]
            [clojure.java.io :as io]
            [langohr.basic :as lb])
  (:import [clojure_mailgun_server.mailer.mailgun EmailRequest]))

(def ^{:const true}
  default-exchange-name "")

(defn message-handler
  [ch {:keys [content-type delivery-tag type] :as meta} ^bytes payload]
  (let [msg (json/parse-stream (io/reader payload))
        msg# (walk/keywordize-keys msg)
        email-request (EmailRequest. (:to msg#) (:subject msg#) (:template msg#) (:values msg#))]
    (timbre/info "[Processing email for Subject through MQ" (:subject email-request) " to " (:to email-request)
    (mailgun/send-email email-request))))

(defn -main
  [& args]
  (let [conn (rmq/connect)
        ch (lch/open conn)
        qname "clojure-mailgun-server.message-queue"]
    (println (format "[main] subscriber Connected. Channel id: %d" (.getChannelNumber ch)))
    (lq/declare ch qname {:exclusive false :auto-delete true})
    (lc/subscribe ch qname message-handler {:auto-ack true})))
{'fraction_non_alphanumeric': 0.14301430143014301, 'fraction_numerical': 0.0, 'mean_word_length': 2.9766763848396502, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1083455', 'n_tokens_mistral': 934, 'n_tokens_neox': 901, 'n_words': 232}