Permalink
Browse files

Add a raw option to amqp-peek.

This option skips the automatic deserialization of messages from the
queue. This is useful if you want to confirm what the actual message
content on the queue looks like.

I need to add this option to amqp-dequeue and amqp-pop.
  • Loading branch information...
1 parent 491d223 commit a7fc1825cdb0b9df9abe9a4a3cffef2f61626415 @dougbarth committed Oct 7, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 bin/amqp-peek
View
@@ -22,6 +22,7 @@ class PeekCommand < AmqpUtils::Command
options.opt :quiet, 'Suppresses non-message content output',
:short => 'q', :default => false
options.opt :num, 'Number of msgs to peek',:short => 'n', :default => 1
+ options.opt :raw, 'Do not deserialize message for display', :default => false
end
def validate
@@ -40,7 +41,13 @@ class PeekCommand < AmqpUtils::Command
queue.pop(:ack => true) do |header, message|
if message
puts "(#{@queue})" unless options[:quiet]
- deserialized_message = AmqpUtils::Serialization.deserialize(header.properties[:content_type], message)
+
+ if options[:raw]
+ deserialized_message = message
+ else
+ deserialized_message = AmqpUtils::Serialization.deserialize(header.properties[:content_type], message)
+ end
+
@formatter.generate(STDOUT, header, deserialized_message)
else
puts "(#{@queue}) empty"

0 comments on commit a7fc182

Please sign in to comment.