Fork me on GitHub
#mount
<
2018-03-26
>
PB16:03:36

Hey all, quick question. I'd like to use mount to start several rabbitmq queues. In doing so I'm using a for to iterate over the queue names, start the queue, and returns a vector of vectors of [channel conn]. My issue is that the call to :stop is returning the following error:

No implementation of method: :close of protocol: #'langohr.core/Closeable
   found for class: clojure.lang.PersistentVector
. Is what I'm doing the wrong way to tackle this?

PB16:03:37

And while I'm debugging, I'm unable to clear the defstate, so as a result am unable to iterate because when I start the queues. I'm unable to stop the component

tolitius16:03:44

looks like you are passing a vector to your :stop function that calls (close ..) on it

tolitius16:03:07

can you show the actual state definition?

PB16:03:14

I can indeed. give me 1 minute

PB16:03:34

(defstate zoom
  :start (for [q [:my-queue]]
           (let [[ch conn] (rmq/start-queue q)]
             (log/info "Starting queue")
             (rmq/subscribe-to-queue ch q handler)
             [ch conn]))
  :stop (let [queues zoom]
          (for [[ch conn :as q] queues]
            (prn "Stopping queue" )
            (rmq/stop-queue ch conn))))

tolitius16:03:37

where do queues come from?

tolitius16:03:01

also I don't see q or zoom actually used in the :stop function

PB16:03:49

My bad, queues, should be zoom. Messed up removing identifiable information

tolitius16:03:30

can you do (println "stopping queue. channel:" ch ", connection:" conn) instead of (prn "Stopping queue" )?

PB16:03:04

I can, but each time I "start" the queues. I am unable to stop the queues as stop throws that error I pasted above. Is there a way to reset the state?

PB16:03:10

Without restarting my repl

tolitius17:03:57

there is a way to clear the reference, but in this case I would suggest to either: * restart the repl if possible, since you would not want to leave stale connections around * introspect #'yourns/zoom state to figure out how to stop it manually

tolitius17:03:54

at this point, I can see that the state code your provided is a bit psedo coded: i.e. there is also no handler + :as q is not used, etc.. so it is easier to restart the repl and see what println reveals

PB17:03:05

Heh, it seems that restarting the repl fixed this

PB17:03:16

I guess it was some left-over state that stopped this from working

PB17:03:39

Sorry, that stuff was there for debugging purposes, there is a little cleanup to be done

tolitius17:03:56

sure, not a problem. so your :stop function now works?

PB17:03:15

It does