Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
plugins/routing/activemq: Take array of hosts
Browse files Browse the repository at this point in the history
In the ActiveMQ routing plug-in, interpret ACTIVEMQ_HOST as
a comma-separated list of host:port pairs, and use this list of hosts when
connecting to ActiveMQ for redundancy.

This commit fixes bug 1102432.
  • Loading branch information
Miciah committed May 29, 2014
1 parent 04dabd8 commit 00e9410
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@

config.routing_activemq = {
:topic => conf.get("ACTIVEMQ_TOPIC", "/topic/routing"),
:hosts => conf.get("ACTIVEMQ_HOST", "127.0.0.1").split(',').map do |hp|
hp.split(":").instance_eval do |h,p|
{
:host => h,
# Originally, ACTIVEMQ_HOST allowed specifying only one host, with
# the port specified separately in ACTIVEMQ_PORT.
:port => p || conf.get("ACTIVEMQ_PORT", "61613"),
}
end
end,
:username => conf.get("ACTIVEMQ_USERNAME", "routinginfo"),
:password => conf.get("ACTIVEMQ_PASSWORD", "routinginfopasswd"),
:host => conf.get("ACTIVEMQ_HOST", "127.0.0.1"),
:port => conf.get("ACTIVEMQ_PORT", "61613"),
:debug => conf.get_bool("ACTIVEMQ_DEBUG", "false"),
}
end
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ def publish(topic, msg)
end
end.new
else
@conn = Stomp::Connection.open Rails.application.config.routing_activemq[:username],
Rails.application.config.routing_activemq[:password],
Rails.application.config.routing_activemq[:host],
Rails.application.config.routing_activemq[:port],
true
@conn = Stomp::Connection.open({
:hosts => Rails.application.config.routing_activemq[:hosts].map do |host|
host.merge({
:login => Rails.application.config.routing_activemq[:username],
:passcode => Rails.application.config.routing_activemq[:password],
})
end,
:reliable => true,
})
end
end

Expand Down

0 comments on commit 00e9410

Please sign in to comment.