Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the uberjar after upgrading from 3.7.0 to 4.0.0 #93

Closed
bvsn opened this issue Jun 14, 2017 · 2 comments
Closed

Problem with the uberjar after upgrading from 3.7.0 to 4.0.0 #93

bvsn opened this issue Jun 14, 2017 · 2 comments

Comments

@bvsn
Copy link

bvsn commented Jun 14, 2017

Hello.

I had a problem when I upgraded my langohr dependency from 3.7.0 to 4.0.0. I can't run lein uberjar anymore because it hangs up.

(ns core
  (:require [langohr.core :as lc]
            [langohr.channel :as lch]))


(def conn (lc/connect {:host "127.0.0.1"
                       :port 5672
                       :vhost "/"}}))

(def ch (lch/open conn))


(defn publish
  [payload queue]
  (lb/publish channel queue queue payload {:content-type "text/plain"}))

To fix it I moved my connection inside the publish function. But I think that it's a bad solution to create and close so much TCP connections.

My project.clj

(defproject some "0.1.0"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :dependencies [[org.clojure/clojure "1.8.0"]
                 [cheshire "5.7.1"]

                 [compojure "1.6.0"]
                 [ring-cors "0.1.10"]
                 [ring/ring-core "1.6.1"]
                 [ring/ring-devel "1.6.1"]
                 [org.immutant/web "2.1.8"]
                 [com.novemberain/langohr "3.7.0"]

                 [com.novemberain/welle "3.0.0"]]

  :profiles {:uberjar {:aot :all
                       :omit-source true
                       :uberjar-name "some.jar"}}

  :main core)
@michaelklishin
Copy link
Owner

Please use mailing list for questions in the future.

Your problem is that you open a connection in top level namespace code. Any potentially blocking operation will block the compiler.

You want to use Component or a similar library that makes it easier to initialise dependencies and store them in application-wide state without using top level namespace code.

@michaelklishin
Copy link
Owner

Also Component will make it easy to reset system state, e.g. between tests, while with connections stored in vars all your options (alter-var-root and such) are hacky and introduce mutable shared state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants