diff options
| author | Luke Kanies <luke@madstop.com> | 2009-05-17 23:20:34 -0500 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-05-18 17:07:17 +1000 |
| commit | a18298a0a9a0d465348164c21fc3dd433aeaa7fc (patch) | |
| tree | f7040f0996b527bacfba308c3b56e74d17974aad /lib | |
| parent | 2771918b9eef9ed26e59688c17c64e86de1b9983 (diff) | |
| download | puppet-a18298a0a9a0d465348164c21fc3dd433aeaa7fc.tar.gz puppet-a18298a0a9a0d465348164c21fc3dd433aeaa7fc.tar.xz puppet-a18298a0a9a0d465348164c21fc3dd433aeaa7fc.zip | |
Refactoring the stomp client and tests a bit
The main goal of this refactor is to tell the client to
be resilient to failures (configured at initialization time),
and to send all messages as persistent messages (configured
for each message).
In the process, the client now parses the queue source URI
and handles each argument separately. The tests are more
thorough, also.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/util/queue/stomp.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/puppet/util/queue/stomp.rb b/lib/puppet/util/queue/stomp.rb index 6f845c314..3a6a99ca2 100644 --- a/lib/puppet/util/queue/stomp.rb +++ b/lib/puppet/util/queue/stomp.rb @@ -1,5 +1,6 @@ require 'puppet/util/queue' require 'stomp' +require 'uri' # Implements the Ruby Stomp client as a queue type within the Puppet::Indirector::Queue::Client # registry, for use with the <tt>:queue</tt> indirection terminus type. @@ -11,11 +12,20 @@ class Puppet::Util::Queue::Stomp attr_accessor :stomp_client def initialize - self.stomp_client = Stomp::Client.new( Puppet[:queue_source] ) + begin + uri = URI.parse(Puppet[:queue_source]) + rescue => detail + raise ArgumentError, "Could not create Stomp client instance - queue source %s is invalid: %s" % [Puppet[:queue_source], detail] + end + unless uri.scheme == "stomp" + raise ArgumentError, "Could not create Stomp client instance - queue source %s is not a Stomp URL: %s" % [Puppet[:queue_source], detail] + end + + self.stomp_client = Stomp::Client.new(uri.user, uri.password, uri.host, uri.port, true) end def send_message(target, msg) - stomp_client.send(stompify_target(target), msg) + stomp_client.send(stompify_target(target), msg, :persistent => true) end def subscribe(target) |
