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
Showing
6 changed files
with
63 additions
and
1 deletion.
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,23 @@ | ||
require "rubygems" | ||
require File.expand_path(File.dirname(__FILE__) + "/../../lib/warren") | ||
|
||
Signal.trap("INT") { AMQP.stop { EM.stop } } | ||
Signal.trap("TERM") { AMQP.stop { EM.stop } } | ||
|
||
# Listen to the main queue | ||
q = "main" | ||
puts "Listening to the #{q} queue." | ||
|
||
# Setup the connection directly this time | ||
Warren::Queue.connection = {:user => "caius", :pass => "caius", :vhost => "/"} | ||
|
||
# Set the secret key | ||
require File.expand_path(File.dirname(__FILE__) + "/secret") | ||
Warren::MessageFilter::SharedSecret.key = SUPER_SECRET_KEY | ||
# And add the filter | ||
Warren::MessageFilter << Warren::MessageFilter::SharedSecret | ||
|
||
# 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 @@ | ||
SUPER_SECRET_KEY = "This is my super secret string" |
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,38 @@ | ||
require "rubygems" | ||
require File.expand_path(File.dirname(__FILE__) + "/../../lib/warren") | ||
|
||
Signal.trap("INT") { exit! } | ||
Signal.trap("TERM") { exit! } | ||
|
||
# Setup our own connection before generating the queue object | ||
conn = Warren::Connection.new( | ||
:user => "caius", | ||
:pass => "caius", | ||
:vhost => "/", | ||
:default_queue => "main" | ||
) | ||
# 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" | ||
} | ||
] | ||
} | ||
|
||
# Set the secret key | ||
require File.expand_path(File.dirname(__FILE__) + "/secret") | ||
Warren::MessageFilter::SharedSecret.key = SUPER_SECRET_KEY | ||
|
||
# And add the filter | ||
Warren::MessageFilter << Warren::MessageFilter::SharedSecret | ||
|
||
# Push a message onto the queue | ||
p Warren::Queue.publish(:default, data ) |
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
File renamed without changes.
File renamed without changes.