amqp 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -2
- data/CHANGELOG +25 -0
- data/Gemfile +4 -2
- data/README.md +2 -0
- data/{amqp.todo → TODO} +1 -3
- data/amqp.gemspec +3 -3
- data/bin/irb +2 -2
- data/bin/jenkins.sh +25 -0
- data/bin/set_test_suite_realms_up.sh +21 -0
- data/doc/EXAMPLE_01_PINGPONG +1 -1
- data/doc/EXAMPLE_02_CLOCK +1 -1
- data/doc/EXAMPLE_03_STOCKS +1 -1
- data/doc/EXAMPLE_04_MULTICLOCK +1 -1
- data/doc/EXAMPLE_05_ACK +1 -1
- data/doc/EXAMPLE_05_POP +1 -1
- data/doc/EXAMPLE_06_HASHTABLE +1 -1
- data/examples/{mq/ack.rb → ack.rb} +6 -6
- data/examples/{mq/automatic_binding_for_default_direct_exchange.rb → automatic_binding_for_default_direct_exchange.rb} +4 -4
- data/examples/{mq/callbacks.rb → callbacks.rb} +2 -2
- data/examples/{mq/clock.rb → clock.rb} +5 -5
- data/examples/{mq/hashtable.rb → hashtable.rb} +4 -4
- data/examples/{mq/internal.rb → internal.rb} +5 -5
- data/examples/{mq/logger.rb → logger.rb} +5 -5
- data/examples/{mq/multiclock.rb → multiclock.rb} +4 -4
- data/examples/{mq/pingpong.rb → pingpong.rb} +5 -5
- data/examples/{mq/pop.rb → pop.rb} +3 -3
- data/examples/{mq/primes-simple.rb → primes-simple.rb} +0 -0
- data/examples/{mq/primes.rb → primes.rb} +6 -6
- data/examples/{amqp/simple.rb → simple.rb} +1 -1
- data/examples/{mq/stocks.rb → stocks.rb} +5 -5
- data/lib/amqp.rb +8 -112
- data/lib/amqp/basic_client.rb +58 -0
- data/lib/amqp/channel.rb +937 -0
- data/lib/amqp/client.rb +72 -79
- data/lib/{mq → amqp}/collection.rb +12 -2
- data/lib/amqp/connection.rb +115 -0
- data/lib/amqp/exceptions.rb +18 -0
- data/lib/{mq → amqp}/exchange.rb +32 -34
- data/lib/{ext → amqp/ext}/em.rb +1 -1
- data/lib/{ext → amqp/ext}/emfork.rb +0 -0
- data/lib/amqp/frame.rb +3 -3
- data/lib/{mq → amqp}/header.rb +5 -11
- data/lib/{mq → amqp}/logger.rb +2 -2
- data/lib/amqp/protocol.rb +2 -2
- data/lib/{mq → amqp}/queue.rb +20 -17
- data/lib/{mq → amqp}/rpc.rb +20 -8
- data/lib/amqp/server.rb +1 -1
- data/lib/amqp/version.rb +1 -1
- data/lib/mq.rb +20 -964
- data/protocol/codegen.rb +1 -1
- data/research/api.rb +3 -3
- data/research/primes-forked.rb +5 -5
- data/research/primes-processes.rb +5 -5
- data/research/primes-threaded.rb +5 -5
- data/spec/integration/authentication_spec.rb +114 -0
- data/spec/integration/automatic_binding_for_default_direct_exchange_spec.rb +13 -12
- data/spec/{unit/mq → integration}/channel_close_spec.rb +2 -2
- data/spec/{unit/mq → integration}/exchange_declaration_spec.rb +26 -14
- data/spec/{unit/mq → integration}/queue_declaration_spec.rb +4 -4
- data/spec/integration/queue_exclusivity_spec.rb +95 -0
- data/spec/integration/reply_queue_communication_spec.rb +63 -0
- data/spec/integration/store_and_forward_spec.rb +121 -0
- data/spec/integration/topic_subscription_spec.rb +193 -0
- data/spec/integration/workload_distribution_spec.rb +245 -0
- data/spec/spec_helper.rb +16 -32
- data/spec/unit/{mq/mq_basic_spec.rb → amqp/basic_spec.rb} +4 -4
- data/spec/unit/{mq → amqp}/collection_spec.rb +22 -7
- data/spec/unit/amqp/connection_spec.rb +116 -0
- data/spec/unit/amqp/frame_spec.rb +18 -18
- data/spec/unit/amqp/protocol_spec.rb +9 -11
- metadata +54 -49
- data/lib/ext/blankslate.rb +0 -9
- data/spec/mq_helper.rb +0 -70
- data/spec/unit/amqp/client_spec.rb +0 -472
- data/spec/unit/amqp/misc_spec.rb +0 -123
- data/spec/unit/mq/misc_spec.rb +0 -228
- data/spec/unit/mq/queue_spec.rb +0 -71
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
= Version 0.7.1
|
2
|
+
|
3
|
+
* [BUG] AMQP gem no longer conflicts with Builder 2.1.2 on Ruby 1.9.
|
4
|
+
All Ruby on Rails 3 users who run Ruby 1.9 are highly recommended
|
5
|
+
to upgrade!
|
6
|
+
|
7
|
+
* [API] AMQP::Exchange.default no longer caches exchange object between calls
|
8
|
+
because it may lead to very obscure issues when channel that exchange was
|
9
|
+
using is closed (due to connection loss, as part of test suite teardown
|
10
|
+
or in any other way).
|
11
|
+
|
12
|
+
* [API] AMQP::Exchange.default now accepts channel as a parameter.
|
13
|
+
* [API] AMQP::Exchange#channel
|
14
|
+
* [BUG] Basic.Return is not supported by amqp gem yet, but it should not result in obscure exceptions
|
15
|
+
* [API] AMQP::Exchange#publish now supports content type overriding.
|
16
|
+
* [API] Introduce AMQP::Exchange #durable?, #transient?, #auto_deleted? and #passive?
|
17
|
+
* [API] Introduce AMQP::Channel#open?
|
18
|
+
* [BUG] AMQP connection was considered established prematurely.
|
19
|
+
* [API] MQ.logging is removed; please use AMQP.logging from now on.
|
20
|
+
* [API] MQ::Queue class is deprecated; please use AMQP::Queue from now on.
|
21
|
+
* [API] MQ::Exchange class is deprecated; please use AMQP::Exchange from now on.
|
22
|
+
* [API] MQ class is deprecated; please use AMQP::Channel from now on.
|
23
|
+
* [API] require "mq" is deprecated; please use require "amqp" from now on.
|
24
|
+
|
25
|
+
|
1
26
|
= Version 0.7
|
2
27
|
* [BUG] Sync API for queues and exchanges, support for server-generated queues & exchange names (via semi-lazy collection).
|
3
28
|
* [BUG] Sync API for MQ#close (Channel.Close) [issue #34].
|
data/Gemfile
CHANGED
@@ -3,9 +3,11 @@
|
|
3
3
|
source "http://gemcutter.org"
|
4
4
|
|
5
5
|
gem "eventmachine"
|
6
|
-
gem "json" if RUBY_VERSION < "1.9"
|
6
|
+
gem "json" if RUBY_VERSION < "1.9" || ARGV.first == "install"
|
7
|
+
gem "amq-client", :git => "git://github.com/ruby-amqp/amq-client.git", :branch => "master"
|
7
8
|
|
8
9
|
group(:test) do
|
9
10
|
gem "rspec", ">=2.0.0"
|
10
|
-
|
11
|
+
|
12
|
+
gem "amqp-spec", :git => "git://github.com/ruby-amqp/amqp-spec.git", :branch => "master"
|
11
13
|
end
|
data/README.md
CHANGED
@@ -73,10 +73,12 @@ libraries that would block current thread (like [File::Tail](http://rubygems.org
|
|
73
73
|
Links
|
74
74
|
==============================
|
75
75
|
|
76
|
+
* [RDoc](http://rubydoc.info/github/ruby-amqp/amqp/master/file/README.md)
|
76
77
|
* Jabber chat [amqp-dev@conf.netlab.cz](xmpp://amqp-dev@conf.netlab.cz)
|
77
78
|
* [AMQP gem mailing list](http://groups.google.com/group/ruby-amqp)
|
78
79
|
* [AMQP gem at GitHub](http://github.com/amqp-dev/amqp)
|
79
80
|
* [AMQP gem at Gemcutter](http://rubygems.org/gems/amqp)
|
81
|
+
* [Jenkins CI Server](http://jenkins.101ideas.cz/job/AMQP)
|
80
82
|
|
81
83
|
Contributions
|
82
84
|
============================
|
data/{amqp.todo → TODO}
RENAMED
@@ -1,8 +1,6 @@
|
|
1
1
|
- breaks with header values that are nil
|
2
2
|
- breaks with header values that are ruby objects (convert to strings?)
|
3
|
-
- sending utf8 data in 1.9 breaks
|
4
3
|
|
5
|
-
- generate amqp/spec.rb from original xml spec
|
6
4
|
- add peek and pop to queues
|
7
5
|
- use rabbitmq generated consumer tag from basic.consume-ok reply
|
8
6
|
|
@@ -29,4 +27,4 @@
|
|
29
27
|
- handle connection.redirect during connect (for rabbitmq in distributed mode) [or just set insist to true]
|
30
28
|
|
31
29
|
- add amq.queue('name').size{ |num| "#{num} messages in the queue" } (send declare passive, look at declare-ok response)
|
32
|
-
- clean up
|
30
|
+
- clean up AMQP::Channel.default on disconnect
|
data/amqp.gemspec
CHANGED
@@ -7,12 +7,12 @@ require File.expand_path("../lib/amqp/version", __FILE__)
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "amqp"
|
9
9
|
s.version = AMQP::VERSION
|
10
|
-
s.authors = ["Aman Gupta", "Jakub Stastny aka botanicus"]
|
10
|
+
s.authors = ["Aman Gupta", "Jakub Stastny aka botanicus", "Michael S. Klishin"]
|
11
11
|
s.homepage = "http://github.com/ruby-amqp/amqp"
|
12
12
|
s.summary = "AMQP client implementation in Ruby/EventMachine."
|
13
13
|
s.description = "An implementation of the AMQP protocol in Ruby/EventMachine for writing clients to the RabbitMQ message broker."
|
14
14
|
s.cert_chain = nil
|
15
|
-
s.email =
|
15
|
+
s.email = ["bWljaGFlbEBub3ZlbWJlcmFpbi5jb20=\n", "c3Rhc3RueUAxMDFpZGVhcy5jeg==\n"].map { |i| Base64.decode64(i) }
|
16
16
|
|
17
17
|
# files
|
18
18
|
s.files = `git ls-files`.split("\n")
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
# RDoc
|
22
22
|
s.has_rdoc = true
|
23
|
-
s.rdoc_options = '--include=examples'
|
23
|
+
s.rdoc_options = '--include=examples --main README.md'
|
24
24
|
s.extra_rdoc_files = ["README.md"] + Dir.glob("doc/*")
|
25
25
|
|
26
26
|
# Dependencies
|
data/bin/irb
CHANGED
data/bin/jenkins.sh
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
echo -e "\n\n==== Setup ===="
|
4
|
+
source /etc/profile
|
5
|
+
git fetch && git reset origin/master --hard
|
6
|
+
|
7
|
+
# FIXME: Jenkins user doesn't have permissions to run it.
|
8
|
+
# PATH=/usr/sbin:$PATH ./bin/set_test_suite_realms_up.sh
|
9
|
+
echo "~ NOT running ./bin/set_test_suite_realms_up.sh"
|
10
|
+
|
11
|
+
echo -e "\n\n==== Ruby 1.9.2 Head ===="
|
12
|
+
rvm use 1.9.2-head@ruby-amqp
|
13
|
+
gem install bundler --no-ri --no-rdoc
|
14
|
+
bundle install --local; echo
|
15
|
+
bundle exec rspec spec
|
16
|
+
return_status=$?
|
17
|
+
|
18
|
+
echo -e "\n\n==== Ruby 1.8.7 ===="
|
19
|
+
rvm use 1.8.7@ruby-amqp
|
20
|
+
gem install bundler --no-ri --no-rdoc
|
21
|
+
bundle install --local; echo
|
22
|
+
bundle exec rspec spec
|
23
|
+
return_status=$(expr $return_status + $?)
|
24
|
+
|
25
|
+
test $return_status -eq 0
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# guest:guest has full access to /
|
4
|
+
|
5
|
+
rabbitmqctl add_vhost /
|
6
|
+
rabbitmqctl add_user guest guest
|
7
|
+
rabbitmqctl set_permissions -p / guest ".*" ".*" ".*"
|
8
|
+
|
9
|
+
|
10
|
+
# amqp_gem:amqp_gem_password has full access to /amqp_gem_testbed
|
11
|
+
|
12
|
+
rabbitmqctl add_vhost /amqp_gem_testbed
|
13
|
+
rabbitmqctl add_user amqp_gem amqp_gem_password
|
14
|
+
rabbitmqctl set_permissions -p /amqp_gem_testbed amqp_gem ".*" ".*" ".*"
|
15
|
+
|
16
|
+
|
17
|
+
# amqp_gem_reader:reader_password has read access to /amqp_gem_testbed
|
18
|
+
|
19
|
+
rabbitmqctl add_user amqp_gem_reader reader_password
|
20
|
+
rabbitmqctl clear_permissions -p /amqp_gem_testbed guest
|
21
|
+
rabbitmqctl set_permissions -p /amqp_gem_testbed amqp_gem_reader "^---$" "^---$" ".*"
|
data/doc/EXAMPLE_01_PINGPONG
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
== Ping Pong Example
|
2
|
-
:include:
|
2
|
+
:include: pingpong.rb
|
data/doc/EXAMPLE_02_CLOCK
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
== Clock Example
|
2
|
-
:include:
|
2
|
+
:include: clock.rb
|
data/doc/EXAMPLE_03_STOCKS
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
== Stocks Example
|
2
|
-
:include:
|
2
|
+
:include: stocks.rb
|
data/doc/EXAMPLE_04_MULTICLOCK
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
== Muti-format Clock Example
|
2
|
-
:include:
|
2
|
+
:include: multiclock.rb
|
data/doc/EXAMPLE_05_ACK
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
== Ack Example
|
2
|
-
:include:
|
2
|
+
:include: ack.rb
|
data/doc/EXAMPLE_05_POP
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
== Pop Example
|
2
|
-
:include:
|
2
|
+
:include: pop.rb
|
data/doc/EXAMPLE_06_HASHTABLE
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
== HashTable RPC Example
|
2
|
-
:include:
|
2
|
+
:include: hashtable.rb
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
$:.unshift
|
4
|
-
require '
|
3
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
4
|
+
require 'amqp'
|
5
5
|
|
6
6
|
# For ack to work appropriately you must shutdown AMQP gracefully,
|
7
7
|
# otherwise all items in your queue will be returned
|
@@ -9,14 +9,14 @@ Signal.trap('INT') { AMQP.stop { EM.stop } }
|
|
9
9
|
Signal.trap('TERM') { AMQP.stop { EM.stop } }
|
10
10
|
|
11
11
|
AMQP.start(:host => 'localhost') do
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
AMQP::Channel.queue('awesome').publish('Totally rad 1')
|
13
|
+
AMQP::Channel.queue('awesome').publish('Totally rad 2')
|
14
|
+
AMQP::Channel.queue('awesome').publish('Totally rad 3')
|
15
15
|
|
16
16
|
i = 0
|
17
17
|
|
18
18
|
# Stopping after the second item was acked will keep the 3rd item in the queue
|
19
|
-
|
19
|
+
AMQP::Channel.queue('awesome').subscribe(:ack => true) do |h, m|
|
20
20
|
if (i += 1) == 3
|
21
21
|
puts 'Shutting down...'
|
22
22
|
AMQP.stop { EM.stop }
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
$:.unshift
|
3
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'amqp'
|
6
6
|
|
7
7
|
if RUBY_VERSION == "1.8.7"
|
8
8
|
module ArrayExtensions
|
@@ -20,7 +20,7 @@ end
|
|
20
20
|
|
21
21
|
EM.run do
|
22
22
|
connection = AMQP.connect
|
23
|
-
mq =
|
23
|
+
mq = AMQP::Channel.new(connection)
|
24
24
|
|
25
25
|
show_stopper = Proc.new do
|
26
26
|
$stdout.puts "Stopping..."
|
@@ -42,7 +42,7 @@ EM.run do
|
|
42
42
|
queues = [queue1, queue2, queue3]
|
43
43
|
|
44
44
|
# Rely on default direct exchange binding, see section 2.1.2.4 Automatic Mode in AMQP 0.9.1 spec.
|
45
|
-
exchange =
|
45
|
+
exchange = AMQP::Channel::Exchange.default
|
46
46
|
|
47
47
|
queue1.subscribe do |payload|
|
48
48
|
puts "Got #{payload} for #{queue1.name}"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
$:.unshift File.expand_path("../../../lib", __FILE__)
|
4
|
-
require "
|
4
|
+
require "amqp"
|
5
5
|
|
6
6
|
AMQP.start(:host => "localhost") do |connection|
|
7
7
|
|
@@ -13,7 +13,7 @@ AMQP.start(:host => "localhost") do |connection|
|
|
13
13
|
end
|
14
14
|
|
15
15
|
@counter = 0
|
16
|
-
amq =
|
16
|
+
amq = AMQP::Channel.new
|
17
17
|
|
18
18
|
3.times do
|
19
19
|
amq.queue("") do |queue|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
$:.unshift
|
4
|
-
require '
|
3
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
4
|
+
require 'amqp'
|
5
5
|
|
6
6
|
AMQP.start(:host => 'localhost') do |connection|
|
7
7
|
|
@@ -18,7 +18,7 @@ AMQP.start(:host => 'localhost') do |connection|
|
|
18
18
|
|
19
19
|
# AMQP.logging = true
|
20
20
|
|
21
|
-
clock =
|
21
|
+
clock = AMQP::Channel.new.fanout('clock')
|
22
22
|
EM.add_periodic_timer(1) {
|
23
23
|
puts
|
24
24
|
|
@@ -26,12 +26,12 @@ AMQP.start(:host => 'localhost') do |connection|
|
|
26
26
|
clock.publish(Marshal.dump(time))
|
27
27
|
}
|
28
28
|
|
29
|
-
amq =
|
29
|
+
amq = AMQP::Channel.new
|
30
30
|
amq.queue('every second').bind(amq.fanout('clock')).subscribe { |time|
|
31
31
|
log 'every second', :received, Marshal.load(time)
|
32
32
|
}
|
33
33
|
|
34
|
-
amq =
|
34
|
+
amq = AMQP::Channel.new
|
35
35
|
amq.queue('every 5 seconds').bind(amq.fanout('clock')).subscribe { |time|
|
36
36
|
time = Marshal.load(time)
|
37
37
|
log 'every 5 seconds', :received, time if time.strftime('%S').to_i % 5 == 0
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
$:.unshift
|
4
|
-
require '
|
3
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
4
|
+
require 'amqp'
|
5
5
|
|
6
6
|
AMQP.start(:host => 'localhost') do |connection|
|
7
7
|
|
@@ -35,9 +35,9 @@ AMQP.start(:host => 'localhost') do |connection|
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
server =
|
38
|
+
server = AMQP::Channel.new.rpc('hash table node', HashTable.new)
|
39
39
|
|
40
|
-
client =
|
40
|
+
client = AMQP::Channel.new.rpc('hash table node')
|
41
41
|
client.set(:now, time = Time.now)
|
42
42
|
client.get(:now) do |res|
|
43
43
|
log 'client', :now => res, :eql? => res == time
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
$:.unshift
|
4
|
-
require '
|
3
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
4
|
+
require 'amqp'
|
5
5
|
require 'pp'
|
6
6
|
|
7
7
|
EM.run do
|
@@ -10,13 +10,13 @@ EM.run do
|
|
10
10
|
connection = AMQP.connect(:host => 'localhost', :logging => false)
|
11
11
|
|
12
12
|
# open a channel on the AMQP connection
|
13
|
-
channel =
|
13
|
+
channel = AMQP::Channel.new(connection)
|
14
14
|
|
15
15
|
# declare a queue on the channel
|
16
|
-
queue =
|
16
|
+
queue = AMQP::Channel::Queue.new(channel, 'queue name')
|
17
17
|
|
18
18
|
# create a fanout exchange
|
19
|
-
exchange =
|
19
|
+
exchange = AMQP::Channel::Exchange.new(channel, :fanout, 'all queues')
|
20
20
|
|
21
21
|
# bind the queue to the exchange
|
22
22
|
queue.bind(exchange)
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
$:.unshift
|
4
|
-
require '
|
5
|
-
require '
|
3
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
4
|
+
require 'amqp'
|
5
|
+
require 'amqp/logger'
|
6
6
|
|
7
|
-
Logger =
|
7
|
+
Logger = AMQP::Channel::Logger
|
8
8
|
|
9
9
|
AMQP.start(:host => 'localhost') do
|
10
10
|
if ARGV[0] == 'server'
|
11
11
|
|
12
|
-
|
12
|
+
AMQP::Channel.queue('logger').bind(AMQP::Channel.fanout('logging', :durable => true)).subscribe { |msg|
|
13
13
|
msg = Marshal.load(msg)
|
14
14
|
require 'pp'
|
15
15
|
pp(msg)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
$:.unshift
|
4
|
-
require '
|
3
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
4
|
+
require 'amqp'
|
5
5
|
require 'time'
|
6
6
|
|
7
7
|
AMQP.start(:host => 'localhost') do |connection|
|
@@ -19,7 +19,7 @@ AMQP.start(:host => 'localhost') do |connection|
|
|
19
19
|
|
20
20
|
#AMQP.logging = true
|
21
21
|
|
22
|
-
clock =
|
22
|
+
clock = AMQP::Channel.new.headers('multiformat_clock')
|
23
23
|
EM.add_periodic_timer(1) {
|
24
24
|
puts
|
25
25
|
|
@@ -32,7 +32,7 @@ AMQP.start(:host => 'localhost') do |connection|
|
|
32
32
|
}
|
33
33
|
|
34
34
|
["iso8601", "rfc2822"].each do |format|
|
35
|
-
amq =
|
35
|
+
amq = AMQP::Channel.new
|
36
36
|
amq.queue(format.to_s).bind(amq.headers('multiformat_clock'), :arguments => {"format" => format}).subscribe { |time|
|
37
37
|
log "received #{format}", time
|
38
38
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
$:.unshift
|
4
|
-
require '
|
3
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
4
|
+
require 'amqp'
|
5
5
|
|
6
6
|
AMQP.start(:host => 'localhost') do |connection|
|
7
7
|
|
@@ -18,7 +18,7 @@ AMQP.start(:host => 'localhost') do |connection|
|
|
18
18
|
|
19
19
|
# AMQP.logging = true
|
20
20
|
|
21
|
-
amq =
|
21
|
+
amq = AMQP::Channel.new
|
22
22
|
EM.add_periodic_timer(1) {
|
23
23
|
puts
|
24
24
|
|
@@ -26,13 +26,13 @@ AMQP.start(:host => 'localhost') do |connection|
|
|
26
26
|
amq.queue('one').publish('ping')
|
27
27
|
}
|
28
28
|
|
29
|
-
amq =
|
29
|
+
amq = AMQP::Channel.new
|
30
30
|
amq.queue('one').subscribe { |msg|
|
31
31
|
log 'one', :received, msg, :sending, 'pong'
|
32
32
|
amq.queue('two').publish('pong')
|
33
33
|
}
|
34
34
|
|
35
|
-
amq =
|
35
|
+
amq = AMQP::Channel.new
|
36
36
|
amq.queue('two').subscribe { |msg|
|
37
37
|
log 'two', :received, msg
|
38
38
|
}
|