           resolve-channel (merge doi-resolve-channels)]
       
       ; Stick the DOIs on a channel for them to be resolved asynchronously and returned via doi-resolve-channels.
-      ; Bit of a hack - put a non-resolvable DOI on the channel to start the worker off.
-      ; Otherwise they never get started and never close their doi-resolve-channels.
-      (doseq [_ (range num-return-chans)]
-        (>!! doi-channel "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"))
-      
       (go
         (doseq [doi dois]
-          (>!! doi-channel doi))
+          (locking *out* (prn "Spool" doi))
+          (>! doi-channel doi))
         (prn "Closing DOI channel")
         (close! doi-channel))
-      
+            
       ; Get resolutions from the merged doi-resolve-channel and insert them.
       ; TODO maybe batch into transactions?
       (loop [resolution (<!! resolve-channel)]
         (when resolution
           (let [[doi first-redirect last-redirect] resolution]
             (insert-resolutions doi first-redirect last-redirect))
-          (recur (<!! dois-resolved-channel)))))))+          (recur (<!! resolve-channel)))))))

  (go
     (loop [doi (<! doi-channel)]
       (when doi
         (locking *out* (prn "Get resolutions for" doi))
         (let [result (get-resolutions doi)]
           (if result
             (let [[first-redirect last-redirect] result]
                 (locking *out* (prn "Return to channel" ch doi))
                 (>!! ch [doi first-redirect last-redirect]))
             (do
               (locking *out* (prn "Close ch" ch))
               (close! ch))))
         (recur (<!! doi-channel))))))

(defn run-doi-resolution []
  ; Insert recently published.
  (let [yesterday (t/minus (t/now) (t/weeks 1))
        recently-published (k/select d/events-isam (k/where {:type issued-type-id :event [>= (coerce/to-sql-date yesterday)]}))]
    (doseq [event recently-published]
      (prn "Add to resolutions table" (:doi event))
      (k/exec-raw ["INSERT INTO resolutions (doi) VALUES (?) ON DUPLICATE KEY UPDATE doi = doi"

          first-redirect (second redirects)
          last-redirect (last redirects)
          ok (= 200 (:status result))]
          (locking *out* (prn "Finish resolve" doi ok))
          (when ok
            [first-redirect last-redirect]))
    (catch Exception _ nil)))
