Permalink
Browse files

Support "advanced" connection factory settings

  • Loading branch information...
michaelklishin committed Sep 22, 2012
1 parent 2d916ae commit 1cf3651d0f74ade4de17558a3c4bcb2b9af63031
Showing with 22 additions and 4 deletions.
  1. +10 −0 ChangeLog.md
  2. +12 −4 src/clojure/langohr/core.clj
View
@@ -1,5 +1,15 @@
## Changes between Langohr 1.0.0-beta4 and 1.0.0-beta5
+### More Connection Settings
+
+`langohr.core/connect` now supports several more options:
+
+ * `:ssl` (true or false): when true, Langohr will use the default SSL protocol (SSLv3) and the default (trusting) trust manager
+ * `:ssl-context` (`javax.net.ssl.SSLContext`): SSL context to use to create connection factory
+ * `:sasl-config` (`com.rabbitmq.client.SaslConfig`): use if you need to use a custom SASL config
+ * `:socket-factory` (`javax.net.SocketFactory`): use if you need to use a custom socket factory
+
+
### Client Capabilities
Langohr now provides its capabilities to the broker so it's possible to tell the difference between
@@ -124,15 +124,23 @@
"Creates connection factory from given attributes"
[settings]
(let [{:keys [host port username password vhost
- requested-heartbeat connection-timeout]
+ requested-heartbeat connection-timeout ssl ssl-context socket-factory sasl-config]
:or {requested-heartbeat ConnectionFactory/DEFAULT_HEARTBEAT
- connection-timeout ConnectionFactory/DEFAULT_CONNECTION_TIMEOUT} } (normalize-settings settings)]
- (doto (ConnectionFactory.)
+ connection-timeout ConnectionFactory/DEFAULT_CONNECTION_TIMEOUT} } (normalize-settings settings)
+ cf (ConnectionFactory.)]
+ (when ssl
+ (.useSslProtocol cf))
+ (doto cf
(.setClientProperties client-properties)
(.setUsername username)
(.setPassword password)
(.setVirtualHost vhost)
(.setHost host)
(.setPort port)
(.setRequestedHeartbeat requested-heartbeat)
- (.setConnectionTimeout connection-timeout))))
+ (.setConnectionTimeout connection-timeout))
+ (when sasl-config
+ (.setSaslConfig cf sasl-config))
+ (when ssl-context
+ (.useSslProtocol cf ^javax.net.ssl.SSLContext ssl-context))
+ cf))

0 comments on commit 1cf3651

Please sign in to comment.