Skip to content

Instantly share code, notes, and snippets.

@meschbach
Created March 1, 2015 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meschbach/b1e73a43ab189a6ce8ed to your computer and use it in GitHub Desktop.
Save meschbach/b1e73a43ab189a6ce8ed to your computer and use it in GitHub Desktop.
Simpel Ruby STOMP Client
This Gist is really part of an article Mark Eschbach wrote at http://meschbach.com/kb/simple-ruby-stomp-client.html.
#!/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
#!/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