Created
February 17, 2010 16:19
-
-
Save craigw/306764 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/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