cwyckoff-rosetta_queue 0.3.0 → 0.3.3

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.
Files changed (51) hide show
  1. data/History.txt +26 -3
  2. data/README.rdoc +4 -149
  3. data/Rakefile +3 -0
  4. data/VERSION.yml +2 -2
  5. data/cucumber.yml +1 -1
  6. data/examples/sample_amqp_consumer.rb +45 -0
  7. data/examples/sample_amqp_fanout_consumer.rb +52 -0
  8. data/examples/sample_amqp_fanout_producer.rb +18 -0
  9. data/examples/sample_amqp_producer.rb +16 -0
  10. data/features/filtering.feature +31 -0
  11. data/features/messaging.feature +47 -0
  12. data/features/step_definitions/common_messaging_steps.rb +82 -0
  13. data/features/step_definitions/filtering_steps.rb +17 -0
  14. data/features/step_definitions/point_to_point_steps.rb +22 -0
  15. data/features/step_definitions/publish_subscribe_steps.rb +25 -0
  16. data/features/support/env.rb +25 -0
  17. data/features/support/sample_consumers.rb +29 -0
  18. data/lib/rosetta_queue.rb +3 -2
  19. data/lib/rosetta_queue/adapter.rb +1 -1
  20. data/lib/rosetta_queue/adapters/amqp.rb +48 -0
  21. data/lib/rosetta_queue/adapters/amqp_evented.rb +132 -0
  22. data/lib/rosetta_queue/adapters/amqp_synch.rb +48 -69
  23. data/lib/rosetta_queue/adapters/beanstalk.rb +56 -0
  24. data/lib/rosetta_queue/adapters/stomp.rb +16 -1
  25. data/lib/rosetta_queue/consumer_managers/base.rb +3 -1
  26. data/lib/rosetta_queue/consumer_managers/threaded.rb +23 -4
  27. data/lib/rosetta_queue/core_ext/string.rb +22 -0
  28. data/lib/rosetta_queue/core_ext/time.rb +20 -0
  29. data/lib/rosetta_queue/filters.rb +1 -1
  30. data/lib/rosetta_queue/logger.rb +1 -1
  31. data/lib/rosetta_queue/message_handler.rb +6 -0
  32. data/spec/rosetta_queue/adapter_spec.rb +101 -0
  33. data/spec/rosetta_queue/adapters/amqp_synchronous_spec.rb +278 -0
  34. data/spec/rosetta_queue/adapters/beanstalk_spec.rb +47 -0
  35. data/spec/rosetta_queue/adapters/fake_spec.rb +72 -0
  36. data/spec/rosetta_queue/adapters/null_spec.rb +31 -0
  37. data/spec/rosetta_queue/adapters/shared_adapter_behavior.rb +38 -0
  38. data/spec/rosetta_queue/adapters/shared_fanout_behavior.rb +20 -0
  39. data/spec/rosetta_queue/adapters/stomp_spec.rb +126 -0
  40. data/spec/rosetta_queue/consumer_managers/evented_spec.rb +56 -0
  41. data/spec/rosetta_queue/consumer_managers/shared_manager_behavior.rb +26 -0
  42. data/spec/rosetta_queue/consumer_managers/threaded_spec.rb +51 -0
  43. data/spec/rosetta_queue/consumer_spec.rb +99 -0
  44. data/spec/rosetta_queue/core_ext/string_spec.rb +15 -0
  45. data/spec/rosetta_queue/destinations_spec.rb +34 -0
  46. data/spec/rosetta_queue/filters_spec.rb +44 -0
  47. data/spec/rosetta_queue/producer_spec.rb +66 -0
  48. data/spec/rosetta_queue/shared_messaging_behavior.rb +21 -0
  49. data/spec/spec.opts +4 -0
  50. data/spec/spec_helper.rb +47 -0
  51. metadata +68 -19
data/History.txt CHANGED
@@ -1,9 +1,32 @@
1
- == 0.1.x (git)
1
+ == 0.2.x (git)
2
2
 
3
3
  === New features
4
+ === Bufixes
5
+
6
+ == 0.2.0
7
+ === New features
8
+ * Synchronous AMQP adapter (Chris Wyckoff - Lead Media Partners)
9
+ * Uses celldee's synchronous AMQP client, 'Bunny'.
10
+ * Added .delete method to Consumer class (Chris Wyckoff - Lead Media Partners)
11
+ * Allows user to purge a queue.
12
+ * Works for AMQP adapters only.
13
+ === Bufixes
14
+ * client :ack now working. (Chris Wyckoff - Lead Media Partners)
15
+
16
+ == 0.1.4
17
+
18
+ === New features
19
+ * Removed dependency on ActiveSupport and brought over needed String methods. (Derek and Matt - Greenview Data, Inc.)
20
+ * Safer shutdown in ThreadedManager (Rob Sanheim - Relevance)
21
+ * Beanstalk Adaper (David Brady - Lead Media Partners)
22
+ * Still needs some work to have it take advantage of beanstalk's subscribe functionality.
23
+ * Synchronous AMQP adapter
24
+ * Uses celldee's synchronous AMQP client, 'Bunny'.
25
+ * Added .delete method to Consumer class
26
+ * Allows user to purge a queue.
27
+ * Works for AMQP adapters only.
4
28
  * Beanstalk Adaper (David Brady)
5
29
  * Still needs some work to have it take advantage of beanstalk's subscribe funtionality.
6
- === Bufixes
7
30
 
8
31
  == 0.1.0 / 2008-01-28 - Initial Release
9
- RosettaQueue was realased in the wild! RQ's initial development was primarily sponsored by Alliance Health Networks (thanks!!). The original authors were Chris Wyckoff and Ben Mabey.The initial release included adapters for stomp and amqp, in addition to a null and fake adapters for testing.
32
+ RosettaQueue was realased in the wild! RQ's initial development was primarily sponsored by Alliance Health Networks (thanks!!). The original authors were Chris Wyckoff and Ben Mabey. The initial release included adapters for stomp and amqp, in addition to a null and fake adapters for testing.
data/README.rdoc CHANGED
@@ -2,155 +2,10 @@
2
2
 
3
3
  Rosetta Queue is a messaging gateway API with adapters for many messaging systems available in Ruby. Messaging systems can be easily switched out with a small configuration change. Code for testing on the object and application level is also provided.
4
4
 
5
- The adapters provided currently are for stomp, amqp, and beanstalk. We would like to add adapters for other messaging gateways. The stomp adapter has been used in production along side with Apache's ActiveMQ. The amqp adapter currently works along side RabbitMQ and passes the acceptance tests but as of yet has not been used in production.
6
-
7
-
8
- == Quick Tutorial
9
-
10
- Note: The API will most likely change until we reach 1.0. We will be moving to a more concise API (i.e. queue(:test_queue) << message, etc...) We will also be changing how exceptions are handled.
11
-
12
- When using Rosetta Queue in an application you will need to configure the queues, adapters, and filters (optional). These configurations should be placed in a file that gets loaded once when your program starts. If you are using Rails then a good place for this is config/initializers/rosetta_queue.rb.
13
-
14
-
15
- To set up destinations for producing and consuming messages:
16
-
17
- RosettaQueue::Destinations.define do |queue|
18
- queue.map :test_queue, '/queue/my_test_queue'
19
- end
20
-
21
-
22
- Defining your adapter:
23
-
24
- RosettaQueue::Adapter.define do |a|
25
- a.user = ""
26
- a.password = ""
27
- a.host = "localhost"
28
- a.port = 61613
29
- a.type = "stomp"
30
- end
31
-
32
-
33
- Define a logger for Rosetta Queue to use. The logger should be a standard ruby logger:
34
-
35
- RosettaQueue.logger = Logger.new('/my_project/rosetta_queue.log')
36
-
37
-
38
- You can optionally set up filters that are applied to all messages that are sent and received. For example, if you want to use hashes as messages and serialize them as JSON the following filters (along with ActiveSupport) would accomplish this:
39
-
40
- RosettaQueue::Filters.define do |filter_for|
41
- filter_for.receiving { |message| ActiveSupport::JSON.decode(message) }
42
- filter_for.sending { |hash| hash.to_json }
43
- end
44
-
45
-
46
- To publish a message:
47
-
48
- message = {"hello" => "world!"} # Assuming you have a filter setup
49
- RosettaQueue::Producer.publish(:test_queue, message)
50
-
51
- When consuming messages from a queue you will generally want to create a consumer to handle the messages:
52
-
53
- class TestConsumer
54
- include RosettaQueue::MessageHandler
55
-
56
- subscribes_to :vendor_status
57
- options :persistent => true
58
-
59
- def on_message(message)
60
- puts "We consumed a message: #{message.inspect}"
61
- end
62
-
63
- end
64
-
65
- To fire the consumers up you will want to run a separate process create a manager with all of your consumers.
66
-
67
- require 'rosetta_queue'
68
- require 'rosetta_queue/consumer_managers/threaded'
69
- require 'test_consumer'
70
-
71
- RosettaQueue::ThreadedManager.create do |m|
72
- m.add(TestConsumer.new)
73
- m.start
74
- end
75
-
76
-
77
- It is recommended that you set your adapter to the 'null' adapter for your specs and then include RosettaQueue::Matchers in any example group you are needing to specify behaviour with RosettaQueue. The matchers currently switch out the null adapter for the fake adapter to verify the behaviour. All the matchers for the unit tests are lambda based, like so:
78
-
79
- lambda { model.save }.should publish("foo", :to => :test_queue).
80
-
81
- Please look at the publishing matchers for more information. For examples on how to write acceptance tests for your Rosetta Queue's code please see RosettaQueue's own Cucumber features and read this {blog post}[http://www.benmabey.com/2009/02/17/using-cucumber-to-integrate-distributed-systems-and-test-messaging/].
82
-
83
-
84
- === AMQP
85
-
86
- The AMQP adapter is based on the synchronous AMQP ruby client "Bunny" by celldee [http://github.com/celldee/bunny]. The original AMQP adapter for RosettaQueue was the 'evented' client by Aman Gupta [http://github.com/tmm1/amqp], but the evented model posed some problems for our integration tests. That, and the desire to keep things simple led us to use a synchronous AMQP client.
87
-
88
- ==== Configuration
89
-
90
- If you are using the AMQP adapter, there are some important rules when defining the adapter and mapping your destinations. Two of the basic building blocks of AMQP are queues and exchanges. Queues bind to exchanges in several different ways. A can queue bind to an exchange and requests messages that match a specific routing key, which is called 'direct exchange' and is analogous to the 'point-to-point' messaging pattern. Alternately, queues can bind to an exchange to receive all messages sent to that exchange; this is called 'fanout exchange' and is analogous to the 'publish-subscribe' pattern. So, when you want to define a simple 'direct-exchange' queue, your queue name must begin with the term "queue".
91
-
92
- RosettaQueue::Destinations.define do |queue|
93
- queue.map :test_queue, 'queue.my_test_queue'
94
- end
95
-
96
- And, when you want to define a queue that will bind to a 'fanout-exchange', your queue name must begin with the term "fanout".
97
-
98
- RosettaQueue::Destinations.define do |queue|
99
- queue.map :test_queue, 'fanout.my_test_queue'
100
- end
101
-
102
- Oh, and when defining your adapter, be sure to specify the AMQP adapter as :amqp_synch, not :amqp. This way, if we do get around to adding Aman's evented AMQP client, we can distinguish between the synchronous and asynchronous clients (i.e., :amqp_sync vs. :amqp_asynch).
103
-
104
-
105
- == How to contribute
106
- ----------------------------------------------------------------
107
- Gems you will need:
108
- cucumber, rspec, yaml, stomp, bunny, beanstalk-client
109
-
110
- You should be able to run the rspec code examples (specs) without any brokers running with autospec or 'rake spec'.
111
-
112
- To run the cucumber features you will need the a messaging system setup that can speak stomp and AMQP. We have been using the following brokers in testing:
113
-
114
- === Apache ActiveMQ (for the stomp adapter)
115
- Go to http://activemq.apache.org/download.html to download the latest version, and see http://activemq.apache.org/getting-started.html for installation and configuration instructions.
116
- The stomp client and features should work with ApacheMQ out of the box. If you are running any ApacheMQ servers in production on your network you will want to disable the multicast autodiscovery in conf/activemq.xml. (Around lines 56 and 98.)
117
-
118
- === RabbitMQ (for the amqp adapter)
119
- Download the right tar from here: http://www.rabbitmq.com/download.html and follow the installation directions that comes with it.
120
- The features rely on a user of 'rosetta' being setup with the password of 'password' and added to the default virtualhost. You can set them up like so:
121
-
122
- rabbitmqctl add_user rosetta password
123
- rabbitmqctl map_user_vhost rosetta /
124
-
125
- === Beanstalk (for the beanstalk adapter) ===
126
-
127
- You should set up and run a local instance of beanstalk for your
128
- tests.
129
-
130
- ==== beanstalkd ====
131
-
132
- Mac OSX users can install beanstalkd from ports. Linux users should
133
- check their package manager of choice. This is probably the optimal
134
- method.
135
-
136
- Diehards can clone git://github.com/kr/beanstalkd and build it from
137
- source. It is nontrivial.
138
-
139
- Once installed, you can launch beanstalk by running
140
-
141
- beanstalkd -p 11300
142
-
143
- This will make it listen on localhost on the standard port 11300,
144
- which the specs use. You might also want to daemonize beanstalk with
145
- the -d option but for testing this is not recommended, as the queue
146
- can get stuck with old messages, which will break your specs.
147
-
148
- ==== beanstalk-client ====
149
-
150
- You will also need the Ruby beanstalk-client gem.
151
-
152
- sudo gem install beanstalk-client
153
-
5
+ Documentation can be found on the wiki.[http://wiki.github.com/bmabey/rosetta_queue]
154
6
 
7
+ == Authors
155
8
 
9
+ Ben Mabey [http://github.com/bmabey]
156
10
 
11
+ Chris Wyckoff [http://github.com/cwyckoff]
data/Rakefile CHANGED
@@ -28,3 +28,6 @@ begin
28
28
  rescue LoadError
29
29
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
30
30
  end
31
+
32
+ desc "Default task runs specs"
33
+ task :default => [:spec]
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 1
4
- :patch: 2
3
+ :minor: 2
4
+ :patch: 0
data/cucumber.yml CHANGED
@@ -1 +1 @@
1
- default: features --format pretty
1
+ default: features --format pretty --require features
@@ -0,0 +1,45 @@
1
+ require 'rubygems'
2
+ require File.dirname(__FILE__) + '/../init.rb'
3
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/rosetta_queue/consumer_managers/threaded')
4
+ RosettaQueue.logger = Logger.new(File.expand_path(File.dirname(__FILE__) + '/../../log/rosetta_queue.log'))
5
+
6
+ module RosettaQueue
7
+
8
+ Adapter.define do |a|
9
+ a.user = "rosetta"
10
+ a.password = "password"
11
+ a.host = "localhost"
12
+ a.type = 'amqp_synch'
13
+ end
14
+
15
+ Destinations.define do |dest|
16
+ dest.map :foo, "queue.foo"
17
+ end
18
+
19
+ class MessageHandlerFoo
20
+ include RosettaQueue::MessageHandler
21
+ subscribes_to :foo
22
+ options :ack => true
23
+ attr_reader :msg
24
+
25
+ def on_message(msg)
26
+ puts "FOO received message: #{msg}"
27
+ end
28
+
29
+ end
30
+
31
+ # consumer = RosettaQueue::Consumer.new(MessageHandlerFoo.new)
32
+ # # Thread.new(consumer) do |cons|
33
+ # consumer.receive
34
+ # # end
35
+ # puts "sleeping for 10"
36
+ # sleep 10
37
+ # puts "shutting consumer down"
38
+ # consumer.disconnect
39
+
40
+ ThreadedManager.create do |m|
41
+ m.add MessageHandlerFoo.new
42
+ m.start
43
+ end
44
+
45
+ end
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require File.dirname(__FILE__) + '/../init.rb'
3
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/rosetta_queue/consumer_managers/threaded.rb')
4
+ RosettaQueue.logger = Logger.new(File.expand_path(File.dirname(__FILE__) + '/../../log/rosetta_queue.log'))
5
+
6
+ module RosettaQueue
7
+
8
+ Adapter.define do |a|
9
+ a.user = "rosetta"
10
+ a.password = "password"
11
+ a.host = "localhost"
12
+ a.type = 'amqp_synch'
13
+ end
14
+
15
+ Destinations.define do |dest|
16
+ dest.map :foo, "fanout.foo"
17
+ end
18
+
19
+ class MessageHandlerFoo
20
+ include RosettaQueue::MessageHandler
21
+ subscribes_to :foo
22
+ options :ack => true
23
+ attr_reader :msg
24
+
25
+ def on_message(msg)
26
+ puts "FOO received message: #{msg}"
27
+ ack
28
+ end
29
+
30
+ end
31
+
32
+ class MessageHandlerBar
33
+ include RosettaQueue::MessageHandler
34
+ subscribes_to :foo
35
+ options :ack => true
36
+ attr_reader :msg
37
+
38
+ def on_message(msg)
39
+ puts "BAR received message: #{msg}"
40
+ ack
41
+ end
42
+ end
43
+
44
+
45
+ # threaded version
46
+ ThreadedManager.create do |m|
47
+ m.add MessageHandlerFoo.new
48
+ m.add MessageHandlerBar.new
49
+ m.start
50
+ end
51
+
52
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require File.dirname(__FILE__) + '/../init.rb'
3
+ RosettaQueue.logger = Logger.new(File.expand_path(File.dirname(__FILE__) + '/../../log/rosetta_queue.log'))
4
+
5
+ RosettaQueue::Adapter.define do |a|
6
+ a.user = "rosetta"
7
+ a.password = "password"
8
+ a.host = "localhost"
9
+ a.type = "amqp_synch"
10
+ end
11
+
12
+ RosettaQueue::Destinations.define do |dest|
13
+ dest.map :foo, "fanout.foo"
14
+ end
15
+
16
+
17
+ RosettaQueue::Producer.publish(:foo, "hello there")
18
+
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require File.dirname(__FILE__) + '/../init.rb'
3
+ RosettaQueue.logger = Logger.new(File.expand_path(File.dirname(__FILE__) + '/../../log/rosetta_queue.log'))
4
+
5
+ RosettaQueue::Adapter.define do |a|
6
+ a.user = "rosetta"
7
+ a.password = "password"
8
+ a.host = "localhost"
9
+ a.type = "amqp_synch"
10
+ end
11
+
12
+ RosettaQueue::Destinations.define do |dest|
13
+ dest.map :foo, "queue.foo"
14
+ end
15
+
16
+ RosettaQueue::Producer.publish(:foo, "hello there")
@@ -0,0 +1,31 @@
1
+ Feature: Message Filtering
2
+ In order to save time and prevent lots of typing
3
+ As a RosettaQueue user
4
+ I want to be able to define filters for processing all of my messages
5
+
6
+
7
+ Scenario Outline: receiving filter
8
+ Given RosettaQueue is configured for '<Adapter>'
9
+ And a destination is set with queue '<Queue>' and queue address '<QueueAddress>'
10
+ And a receiving filter is defined to prepend 'Foo' to all messages
11
+ And the message 'Hello World' is published to queue '<Queue>'
12
+ When the message on '<Queue>' is consumed
13
+ Then the consumed message should equal "Foo Hello World"
14
+
15
+ Examples:
16
+ | Adapter | Queue | QueueAddress |
17
+ | amqp_synch | foo | queue.foo |
18
+ # | stomp | foo | queue/foo |
19
+
20
+ Scenario Outline: sending filter
21
+ Given RosettaQueue is configured for '<Adapter>'
22
+ And a destination is set with queue '<Queue>' and queue address '<QueueAddress>'
23
+ And a sending filter is defined to prepend 'Foo' to all messages
24
+ And the message 'Hello World' is published to queue '<Queue>'
25
+ When the message on '<Queue>' is consumed
26
+ Then the consumed message should equal "Foo Hello World"
27
+
28
+ Examples:
29
+ | Adapter | Queue | QueueAddress |
30
+ | amqp_synch | foo | queue.foo |
31
+ # | stomp | foo | queue/foo |
@@ -0,0 +1,47 @@
1
+ Story: Producing and Consuming
2
+
3
+ As a RosettaQueue user
4
+ I want to publish and consume point-to-point using various messaging protocols
5
+ So that I can reliably integrate my systems with a message broker
6
+
7
+ Background:
8
+ Given consumer logs have been cleared
9
+
10
+ Scenario Outline: Point-to-Point
11
+ Given RosettaQueue is configured for '<Adapter>'
12
+ And a destination is set with queue '<Queue>' and queue address '<QueueAddress>'
13
+ And a consumer is listening to queue '<Queue>'
14
+ When a message is published to '<Queue>'
15
+ Then the message should be consumed from '<Queue>'
16
+
17
+ Examples:
18
+ | Adapter | Queue | QueueAddress |
19
+ | amqp_synch | foo | queue.foo |
20
+ | amqp_evented | bar | queue.bar |
21
+ # | stomp | baz | /queue/baz |
22
+ # | beanstalk | baz | baz |
23
+
24
+ Scenario Outline: Delete queue
25
+ Given RosettaQueue is configured for '<Adapter>'
26
+ And a destination is set with queue '<Queue>' and queue address '<QueueAddress>'
27
+ When a message is published to '<Queue>'
28
+ And the queue '<Queue>' is deleted
29
+ Then the queue '<Queue>' should no longer exist
30
+
31
+ Examples:
32
+ | Adapter | Queue | QueueAddress |
33
+ | amqp_synch | foo | queue.foo |
34
+
35
+
36
+ Scenario Outline: Publish-Subscribe
37
+ Given RosettaQueue is configured for '<Adapter>'
38
+ And a destination is set with queue '<Queue>' and queue address '<QueueAddress>'
39
+ And multiple consumers are listening to queue '<Queue>'
40
+ When a message is published to '<Queue>'
41
+ Then multiple messages should be consumed from '<Queue>'
42
+
43
+ Examples:
44
+ | Adapter | QueueAddress | Queue |
45
+ | amqp_synch | fanout.baz | baz |
46
+ # | amqp_evented | queue.foo | foo |
47
+ # | stomp | topic/foo | bar |
@@ -0,0 +1,82 @@
1
+ def eval_consumer_class(queue, log_file="point-to-point.log", klass_name=nil)
2
+ klass_name = "#{queue.to_s.capitalize}Consumer" if klass_name.nil?
3
+ return if Object.const_defined?(klass_name)
4
+ options = {}
5
+ unless @adapter_type == "stomp"
6
+ options = ":ack => true"
7
+ else
8
+ options = ":ack => 'client'"
9
+ end
10
+
11
+ str = <<-EOC
12
+ class #{klass_name}
13
+ include RosettaQueue::MessageHandler
14
+ subscribes_to :#{queue}
15
+ options #{options}
16
+
17
+ def on_message(msg)
18
+ begin
19
+ file_path = "#{CONSUMER_LOG_DIR}/#{log_file}"
20
+ File.open(file_path, "w+") do |f|
21
+ f << msg + " from #{klass_name}"
22
+ end
23
+ rescue Exception => e
24
+ puts e.message
25
+ end
26
+ end
27
+ end
28
+ EOC
29
+
30
+ eval(str)
31
+ Object.const_get(klass_name)
32
+ end
33
+
34
+ Given /^consumer logs have been cleared$/ do
35
+ %w[point-to-point pub-sub fooconsumer barconsumer].each do |file_name|
36
+ file_path = "#{CONSUMER_LOG_DIR}/#{file_name}.log"
37
+ File.delete(file_path) if File.exists?(file_path)
38
+ File.open(file_path, "a+")
39
+ end
40
+ end
41
+
42
+ Given /^RosettaQueue is configured for '(\w+)'$/ do |adapter_type|
43
+ @adapter_type = adapter_type
44
+ RosettaQueue::Adapter.define do |a|
45
+ a.user = "rosetta"
46
+ a.password = "password"
47
+ a.host = "localhost"
48
+ a.type = @adapter_type
49
+ a.port = case @adapter_type
50
+ when /stomp/
51
+ "61613"
52
+ when /beanstalk/
53
+ "11300"
54
+ else
55
+ nil
56
+ end
57
+ end
58
+ end
59
+
60
+ Given /^a destination is set with queue '(.*)' and queue address '(.*)'$/ do |key, queue|
61
+ RosettaQueue::Destinations.define do |dest|
62
+ dest.map key.to_sym, queue
63
+ end
64
+ end
65
+
66
+ Given /^the message '(.+)' is published to queue '(.+)'$/ do |message, queue_name|
67
+ publish_message(message, {:to => queue_name})
68
+ end
69
+
70
+ When /^a message is published to '(\w+)'$/ do |q|
71
+ RosettaQueue::Producer.publish(q.to_sym, "Hello World!")
72
+ # publish_message("Hello World!", {:options => {:to => q}})
73
+ end
74
+
75
+ When /^the queue '(.*)' is deleted$/ do |queue|
76
+ system("rabbitmqctl list_queues | grep #{queue}").should be_true
77
+ RosettaQueue::Consumer.delete(queue.to_sym)
78
+ end
79
+
80
+ Then /^the queue '(.*)' should no longer exist$/ do |queue|
81
+ system("rabbitmqctl list_queues | grep #{queue}").should be_false
82
+ end