Skip to content

Instantly share code, notes, and snippets.

@craigw
Created February 17, 2010 16:19
Show Gist options
  • Save craigw/306764 to your computer and use it in GitHub Desktop.
Save craigw/306764 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
# Run me like this:
#
# ./stompcat.rb mq.example.com /topic/foo.bar.baz.quux
#
require 'rubygems'
require 'smqueue'
require 'json'
configuration = {
:host => ARGV[0],
:name => ARGV[1],
:adapter => :StompAdapter
}
source = SMQueue(configuration)
source.get do |m|
payload = case m.headers["content-type"]
when /^application\/json\s/
JSON[m.body]
else
m.body
end
puts ">>> #{payload}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment