Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alberto Perdomo
committed
Dec 18, 2009
1 parent
ec40265
commit 775270f
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "rubygems" | ||
require "warren" | ||
require "warren/adapters/bunny_adapter" | ||
|
||
Signal.trap("INT") { exit! } | ||
Signal.trap("TERM") { exit! } | ||
|
||
# Listen to the main queue | ||
q = "main" | ||
puts "Listening to the #{q} queue." | ||
|
||
# Setup our own connection before generating the queue object | ||
conn = Warren::Connection.new("development" => { | ||
:user => "guest", | ||
:pass => "guest", | ||
:vhost => "/", | ||
:default_queue => "main", | ||
:logging => false | ||
}) | ||
# Set the connection for the queue | ||
Warren::Queue.connection = conn | ||
|
||
# And attach a block for new messages to fire | ||
Warren::Queue.subscribe(q) do |msg| | ||
p [Time.now, msg] | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require "rubygems" | ||
require "warren" | ||
require "warren/adapters/bunny_adapter" | ||
|
||
Signal.trap("INT") { exit! } | ||
Signal.trap("TERM") { exit! } | ||
|
||
# Setup our own connection before generating the queue object | ||
conn = Warren::Connection.new("development" => { | ||
:user => "guest", | ||
:pass => "guest", | ||
:vhost => "/", | ||
:default_queue => "main", | ||
:logging => false | ||
}) | ||
# Set the connection for the queue | ||
Warren::Queue.connection = conn | ||
# Generate some data to send | ||
data = { | ||
:people => [ | ||
:fred => { | ||
:age => 25, | ||
:location => "Leeds" | ||
}, | ||
:george => { | ||
:age => 32, | ||
:location => "London" | ||
} | ||
] | ||
} | ||
|
||
# Push a message onto the queue | ||
p Warren::Queue.publish(:default, data ) | ||
|
||
# And then push a message onto the queue, returning "foo" | ||
#p Warren::Queue.publish(:default, data) { "foo" } |