Created
March 17, 2012 22:15
-
-
Save ripienaar/2065796 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'stomp' | |
def read_key(type, key=nil, passphrase=nil) | |
return key if key.nil? | |
raise "Could not find key #{key}" unless File.exist?(key) | |
if type == :public | |
key = OpenSSL::PKey::RSA.new(File.read(key)) | |
OpenSSL.errors | |
return key | |
elsif type == :private | |
return OpenSSL::PKey::RSA.new(File.read(key), passphrase) | |
else | |
raise "Can only load :public or :private keys" | |
end | |
end | |
connection = {:hosts => [ {:login => "rip", :passcode => "secret", :host => "stomp", :port => "6164", :ssl => true} ]} | |
@connection = Stomp::Connection.open(connection) | |
@connection.subscribe("/queue/foo") | |
10000.times {|i| | |
@connection.publish("/queue/foo", "*" * 10240) | |
} | |
@connection.publish("/queue/foo", "end") | |
msg = nil | |
count = 0 | |
until msg == "end" | |
msg = @connection.receive.body | |
puts count if (count += 1) % 1000 == 0 | |
puts read_key(:private, "/home/rip/.mcollective.d/rip-private.pem").class if count == 100 | |
puts read_key(:public, "/home/rip/.mcollective.d/rip.pem").class if count == 100 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment