mount

PB 2018-03-26T16:36:36.000114Z

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?

PB 2018-03-26T16:41:37.000675Z

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

tolitius 2018-03-26T16:41:44.000591Z

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

tolitius 2018-03-26T16:42:07.000195Z

can you show the actual state definition?

PB 2018-03-26T16:42:14.000679Z

I can indeed. give me 1 minute

PB 2018-03-26T16:44:34.000485Z

(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))))

tolitius 2018-03-26T16:49:37.000057Z

where do queues come from?

tolitius 2018-03-26T16:50:01.000410Z

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

PB 2018-03-26T16:53:49.000448Z

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

tolitius 2018-03-26T16:56:30.000161Z

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

PB 2018-03-26T16:58:04.000541Z

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?

PB 2018-03-26T16:58:10.000659Z

Without restarting my repl

tolitius 2018-03-26T17:00:57.000336Z

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

tolitius 2018-03-26T17:01:54.000369Z

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

PB 2018-03-26T17:02:05.000681Z

Heh, it seems that restarting the repl fixed this

PB 2018-03-26T17:02:16.000127Z

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

PB 2018-03-26T17:02:39.000435Z

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

tolitius 2018-03-26T17:02:56.000243Z

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

PB 2018-03-26T17:03:15.000810Z

It does

tolitius 2018-03-26T17:03:45.000236Z

great