Created
March 1, 2015 17:40
-
-
Save meschbach/b1e73a43ab189a6ce8ed to your computer and use it in GitHub Desktop.
Simpel Ruby STOMP Client
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
This Gist is really part of an article Mark Eschbach wrote at http://meschbach.com/kb/simple-ruby-stomp-client.html. |
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
#!/usr/local/bin/ruby18 | |
require ‘gem’ | |
require ‘stomp’ | |
port = 61613 | |
client = Stomp::Client.new( “password”, “user”, “broker.host.name”, port ) | |
client.subscribe(‘/queue/stdin’) { | |
| message | | |
if( message.headers[‘type’] == ‘terminate’ ) | |
client.close | |
else | |
puts message.body | |
end | |
} | |
client.join |
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
#!/usr/local/bin/ruby18 | |
require ‘gem’ | |
require ‘stomp’ | |
port = 61613 | |
client = Stomp::Client.new( “password”, “user”, “broker.host.name”, port ) | |
stdin.each { |line| | |
client.send( “/queue/stdin”, line, { ‘amq-msg-type’=>’text’,’type’=>’content’}) | |
} | |
client.send(“/queue/stdin”, “”, {‘amq-msg-type’=>’text’, ‘type’=>’terminate’}) | |
client.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment