目前我有一个 ActiveMQ 实例正在运行,我正在尝试使用 immutant 进行连接。目前,此连接的代码如下所示;
(defn make-ctx
[]
(log/debug "making context")
(let [ctx (m/context :host (:host immutant-host) :port (:port immutant-host))]
(log/debug "context created")
ctx))
(defn make-listener
[ctx]
(let [listener (m/listen topic #(log/debug %) :context ctx)]
(log/debug "listener created")
listener))
(defn immutant-test
[]
(log/debug "testing immutant messaging with ActiveMQ")
(let [ctx (make-ctx)
listener (make-listener ctx)]
(Thread/sleep 15000)
(.close listener)))
虽然我的代码没有使它通过 make-ctx 函数。当它尝试创建上下文时,我收到错误
Exception in thread "main" java.lang.RuntimeException: javax.jms.JMSException: Failed to create session factory
at org.projectodd.wunderboss.messaging.jms.DestinationUtil.mightThrow(DestinationUtil.java:47)
at org.projectodd.wunderboss.messaging.jms.JMSMessagingSkeleton.createContext(JMSMessagingSkeleton.java:64)
at org.projectodd.wunderboss.messaging.jms.JMSMessagingSkeleton.createContext(JMSMessagingSkeleton.java:181)
at immutant.messaging$context.doInvoke(messaging.clj:84)
at clojure.lang.RestFn.invoke(RestFn.java:457)
at jms_test.core$make_ctx.invoke(core.clj:24)
at jms_test.core$immutant_test.invoke(core.clj:37)
at jms_test.core$_main.invoke(core.clj:158)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at jms_test.core.main(Unknown Source)
Caused by: javax.jms.JMSException: Failed to create session factory
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:673)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:112)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:107)
at org.projectodd.wunderboss.messaging.jms.JMSMessagingSkeleton$1.call(JMSMessagingSkeleton.java:73)
at org.projectodd.wunderboss.messaging.jms.DestinationUtil.mightThrow(DestinationUtil.java:45)
... 10 more
Caused by: HornetQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=HQ119013: Timed out waiting to receive cluster topology. Group:null]
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:946)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:669)
... 14 more
immutant-host 定义为
(def immutant-host {:host "127.0.0.1" :port 61616})
我已经能够使用 clamq libray 连接到我的代理,并且能够使用它发送和接收消息。虽然因为应用程序的其余部分是使用不变消息构建的,但如果可能的话,我想坚持使用该库,以免不得不支持多个消息库。