bmabey-rosetta_queue 0.2.0 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/History.txt +6 -3
  2. data/README.rdoc +1 -193
  3. data/Rakefile +7 -1
  4. data/cucumber.yml +1 -1
  5. data/examples/sample_amqp_consumer.rb +13 -3
  6. data/examples/sample_amqp_fanout_consumer.rb +6 -3
  7. data/examples/sample_amqp_fanout_producer.rb +3 -2
  8. data/examples/sample_amqp_producer.rb +2 -1
  9. data/features/filtering.feature +13 -13
  10. data/features/messaging.feature +28 -20
  11. data/features/step_definitions/common_messaging_steps.rb +54 -17
  12. data/features/step_definitions/filtering_steps.rb +2 -2
  13. data/features/step_definitions/point_to_point_steps.rb +19 -9
  14. data/features/step_definitions/publish_subscribe_steps.rb +22 -8
  15. data/features/support/env.rb +2 -0
  16. data/features/support/sample_consumers.rb +6 -6
  17. data/lib/rosetta_queue.rb +1 -0
  18. data/lib/rosetta_queue/adapter.rb +6 -6
  19. data/lib/rosetta_queue/adapters/amqp.rb +6 -3
  20. data/lib/rosetta_queue/adapters/amqp_evented.rb +22 -22
  21. data/lib/rosetta_queue/adapters/amqp_synch.rb +42 -36
  22. data/lib/rosetta_queue/adapters/base.rb +3 -3
  23. data/lib/rosetta_queue/adapters/beanstalk.rb +5 -5
  24. data/lib/rosetta_queue/adapters/fake.rb +5 -5
  25. data/lib/rosetta_queue/adapters/null.rb +9 -9
  26. data/lib/rosetta_queue/adapters/stomp.rb +25 -12
  27. data/lib/rosetta_queue/base.rb +2 -2
  28. data/lib/rosetta_queue/consumer.rb +4 -4
  29. data/lib/rosetta_queue/consumer_managers/base.rb +8 -6
  30. data/lib/rosetta_queue/consumer_managers/evented.rb +5 -5
  31. data/lib/rosetta_queue/consumer_managers/threaded.rb +4 -4
  32. data/lib/rosetta_queue/core_ext/string.rb +3 -3
  33. data/lib/rosetta_queue/core_ext/time.rb +20 -0
  34. data/lib/rosetta_queue/destinations.rb +6 -6
  35. data/lib/rosetta_queue/filters.rb +8 -8
  36. data/lib/rosetta_queue/logger.rb +2 -2
  37. data/lib/rosetta_queue/message_handler.rb +10 -4
  38. data/lib/rosetta_queue/producer.rb +2 -2
  39. data/lib/rosetta_queue/spec_helpers/hash.rb +3 -3
  40. data/lib/rosetta_queue/spec_helpers/helpers.rb +8 -8
  41. data/lib/rosetta_queue/spec_helpers/publishing_matchers.rb +26 -26
  42. data/spec/rosetta_queue/adapter_spec.rb +27 -27
  43. data/spec/rosetta_queue/adapters/amqp_synchronous_spec.rb +21 -1
  44. data/spec/rosetta_queue/adapters/beanstalk_spec.rb +3 -3
  45. data/spec/rosetta_queue/adapters/fake_spec.rb +6 -6
  46. data/spec/rosetta_queue/adapters/null_spec.rb +5 -5
  47. data/spec/rosetta_queue/adapters/shared_adapter_behavior.rb +4 -4
  48. data/spec/rosetta_queue/adapters/shared_fanout_behavior.rb +1 -1
  49. data/spec/rosetta_queue/adapters/stomp_spec.rb +39 -18
  50. data/spec/rosetta_queue/consumer_managers/evented_spec.rb +6 -6
  51. data/spec/rosetta_queue/consumer_managers/shared_manager_behavior.rb +3 -3
  52. data/spec/rosetta_queue/consumer_managers/threaded_spec.rb +5 -5
  53. data/spec/rosetta_queue/consumer_spec.rb +13 -13
  54. data/spec/rosetta_queue/core_ext/string_spec.rb +3 -3
  55. data/spec/rosetta_queue/destinations_spec.rb +8 -8
  56. data/spec/rosetta_queue/filters_spec.rb +16 -16
  57. data/spec/rosetta_queue/producer_spec.rb +15 -15
  58. data/spec/rosetta_queue/shared_messaging_behavior.rb +6 -6
  59. metadata +3 -2
@@ -1,3 +1,44 @@
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
+
1
42
  Given /^RosettaQueue is configured for '(\w+)'$/ do |adapter_type|
2
43
  @adapter_type = adapter_type
3
44
  RosettaQueue::Adapter.define do |a|
@@ -16,30 +57,26 @@ Given /^RosettaQueue is configured for '(\w+)'$/ do |adapter_type|
16
57
  end
17
58
  end
18
59
 
19
- Given /^a point-to-point destination is set$/ do
60
+ Given /^a destination is set with queue '(.*)' and queue address '(.*)'$/ do |key, queue|
20
61
  RosettaQueue::Destinations.define do |dest|
21
- dest.map :foo, "/queue/bar"
22
- end
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})
23
68
  end
24
69
 
25
- Given /^a '(.*)' destination is set$/ do |pub_sub|
26
- case pub_sub
27
- when /fanout/
28
- RosettaQueue::Destinations.define do |dest|
29
- dest.map :foobar, "/fanout/foobar"
30
- end
31
- when /topic/
32
- RosettaQueue::Destinations.define do |dest|
33
- dest.map :foobar, "/topic/foobar"
34
- end
35
- end
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}})
36
73
  end
37
74
 
38
75
  When /^the queue '(.*)' is deleted$/ do |queue|
39
- system("rabbitmqctl list_queues | grep bar").should be_true
76
+ system("rabbitmqctl list_queues | grep #{queue}").should be_true
40
77
  RosettaQueue::Consumer.delete(queue.to_sym)
41
78
  end
42
79
 
43
- Then /^the queue 'foo' should no longer exist$/ do
44
- system("rabbitmqctl list_queues | grep bar").should be_false
80
+ Then /^the queue '(.*)' should no longer exist$/ do |queue|
81
+ system("rabbitmqctl list_queues | grep #{queue}").should be_false
45
82
  end
@@ -5,9 +5,9 @@ Then /^a (receiving|sending) filter is defined to prepend 'Foo' to all messages$
5
5
  end
6
6
  end
7
7
 
8
- When /^the message on "(.+)" is consumed$/ do |queue_name|
8
+ When /^the message on '(.+)' is consumed$/ do |queue_name|
9
9
  # TODO
10
- # @consumed_message = queue(:foo_queue).pop
10
+ # @consumed_message = queue(:foo_queue).pop
11
11
  @consumed_message = consume_once(queue_name.to_sym)
12
12
  end
13
13
 
@@ -1,12 +1,22 @@
1
- Given /^the message "(.+)" is published to queue "(.+)"$/ do |message, queue_name|
2
- publish_message(message, {:options => {:ack => "client"}}.merge(:to => queue_name))
1
+ Given /^a consumer is listening to queue '(.*)'$/ do |queue|
2
+ klass = eval_consumer_class(queue)
3
+ @thread = Thread.new do
4
+ cons = klass.new
5
+ case @adapter_type
6
+ when /evented/
7
+ EM.run do
8
+ RosettaQueue::Consumer.new(cons).receive
9
+ end
10
+ else
11
+ RosettaQueue::Consumer.new(cons).receive
12
+ end
13
+ end
3
14
  end
4
15
 
5
- When /^a message is published to queue '(\w+)'$/ do |q|
6
- publish_message("Hello World!", {:options => {:ack => "client"}}.merge(:to => q))
7
- end
8
-
9
- Then /^the message should be consumed$/ do
10
- RosettaQueue::Consumer.receive(:foo).should =~ /Hello World!/
11
- # consume_once_with(SampleConsumer).should =~ /Hello World!/
16
+ Then /^the message should be consumed from '(.*)'$/ do |queue|
17
+ sleep 1
18
+ file_path = "#{CONSUMER_LOG_DIR}/point-to-point.log"
19
+ # sleep 1 unless File.exists?(file_path)
20
+ File.readlines(file_path).last.should =~ /Hello World! from #{queue.capitalize}Consumer/
21
+ @thread.kill
12
22
  end
@@ -1,11 +1,25 @@
1
- When /^a message is published to '(\w+)'$/ do |topic|
2
- RosettaQueue::Producer.publish(topic.to_sym, "Hello World!", {:durable => true})
3
- # publish_message("Hello World!", {:options => {:ack => "client"}}.merge(:to => topic))
1
+ Given /^multiple consumers are listening to queue '(.*)'$/ do |queue|
2
+ @managers = []
3
+ Thread.new do
4
+ @managers << RosettaQueue::ThreadedManager.create do |m|
5
+ m.add(eval_consumer_class(queue, "fooconsumer.log", "FooConsumer").new)
6
+ m.start
7
+ end
8
+ end
9
+
10
+ Thread.new do
11
+ @managers << RosettaQueue::ThreadedManager.create do |m|
12
+ m.add(eval_consumer_class(queue, "barconsumer.log", "BarConsumer").new)
13
+ m.start
14
+ end
15
+ end
16
+ sleep 5
4
17
  end
5
18
 
6
- Then /^multiple messages should be consumed from the topic$/ do
7
- sleep 1
8
- RosettaQueue::Consumer.receive(:foobar).should =~ /Hello World!/
9
- # RosettaQueue::Consumer.receive(:bar).should =~ /Hello World!/
10
- # consume_once_with(SampleConsumer).should == "Hello World!"
19
+ Then /^multiple messages should be consumed from '(\w+)'$/ do |queue|
20
+ ["FooConsumer", "BarConsumer"].each do |class_name, value|
21
+ file_path = "#{CONSUMER_LOG_DIR}/#{class_name.downcase}.log"
22
+ File.readlines(file_path).last.should =~ /Hello World! from #{class_name}/
23
+ end
24
+ @managers.each {|m| m.stop_threads }
11
25
  end
@@ -5,6 +5,8 @@ require 'rosetta_queue/spec_helpers'
5
5
  require 'spec/expectations'
6
6
  require 'rosetta_queue/spec_helpers'
7
7
 
8
+ CONSUMER_LOG_DIR = File.expand_path(File.dirname(__FILE__) + "/../support/tmp")
9
+
8
10
  begin
9
11
  RosettaQueue.logger = RosettaQueue::Logger.new(File.join(File.dirname(__FILE__), '../../../log', 'rosetta_queue.log'))
10
12
  rescue Errno::ENOENT
@@ -4,14 +4,14 @@ class SampleConsumer
4
4
  include ::RosettaQueue::MessageHandler
5
5
  subscribes_to :foo
6
6
  options :durable => true
7
-
7
+
8
8
  attr_reader :msg
9
-
9
+
10
10
  def on_message(msg)
11
11
  @msg = msg
12
12
  puts "MESSAGE #{msg}"
13
13
  end
14
-
14
+
15
15
  end
16
16
 
17
17
 
@@ -19,11 +19,11 @@ class SampleConsumerTwo
19
19
  include ::RosettaQueue::MessageHandler
20
20
  subscribes_to :foo
21
21
  options :durable => true
22
-
22
+
23
23
  attr_reader :msg
24
-
24
+
25
25
  def on_message(msg)
26
26
  @msg = msg
27
27
  end
28
-
28
+
29
29
  end
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
2
2
 
3
3
  require('rosetta_queue/core_ext/string') unless defined? ActiveSupport
4
+ require('rosetta_queue/core_ext/time') unless defined? ActiveSupport
4
5
 
5
6
  require 'rosetta_queue/adapter'
6
7
  require 'rosetta_queue/base'
@@ -5,15 +5,15 @@ module RosettaQueue
5
5
 
6
6
  class << self
7
7
  attr_writer :user, :password, :host, :port, :options
8
-
8
+
9
9
  def define
10
10
  yield self
11
11
  end
12
-
12
+
13
13
  def reset
14
14
  @user, @password, @host, @port, @options, @adapter_class = nil, nil, nil, nil, nil, nil
15
15
  end
16
-
16
+
17
17
  def type=(adapter_prefix)
18
18
  require "rosetta_queue/adapters/#{adapter_prefix}"
19
19
  @adapter_class = RosettaQueue::Gateway.const_get("#{adapter_prefix.to_s.classify}Adapter")
@@ -28,12 +28,12 @@ module RosettaQueue
28
28
  end
29
29
 
30
30
  private
31
-
31
+
32
32
  def opts
33
33
  raise AdapterException, "Adapter options should be a hash" unless @options.nil? || @options.is_a?(Hash)
34
34
  @options ||= {}
35
35
  end
36
-
36
+
37
37
  end
38
- end
38
+ end
39
39
  end
@@ -7,7 +7,7 @@ module RosettaQueue
7
7
  raise AdapterException, "Unable to discover fanout exchange. Cannot bind queue to exchange!" unless fanout_name
8
8
  fanout_name
9
9
  end
10
- end
10
+ end
11
11
 
12
12
  class Amqp < BaseAdapter
13
13
 
@@ -18,9 +18,12 @@ module RosettaQueue
18
18
 
19
19
  def delete(destination, opts={})
20
20
  exchange_strategy_for(destination, opts).delete(destination)
21
- end
21
+ end
22
22
 
23
- def disconnect(message_handler); end
23
+ def disconnect(message_handler)
24
+ destination = destination_for(message_handler)
25
+ exchange_strategy_for(destination).unsubscribe
26
+ end
24
27
 
25
28
  def receive_once(destination, opts={})
26
29
  exchange_strategy_for(destination, opts).receive_once(destination) do |msg|
@@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + "/amqp.rb")
4
4
 
5
5
  module RosettaQueue
6
6
  module Gateway
7
-
7
+
8
8
  class AmqpEventedAdapter < Amqp
9
9
  private
10
10
 
@@ -21,35 +21,35 @@ module RosettaQueue
21
21
  end
22
22
  end
23
23
  end
24
-
24
+
25
25
  module EventedExchange
26
26
 
27
27
  class BaseExchange
28
-
28
+
29
29
  def initialize(adapter_settings, options={})
30
30
  @adapter_settings, @options = adapter_settings, options
31
31
  end
32
32
 
33
33
  def delete(destination)
34
34
  conn.queue(destination).delete(@options)
35
- end
35
+ end
36
36
 
37
37
  protected
38
-
38
+
39
39
  def channel
40
40
  @channel ||= MQ.new(conn)
41
41
  end
42
-
42
+
43
43
  def conn
44
- vhost = @adapter_settings[:opts][:vhost] || "/"
45
- @conn ||= AMQP.connect(:user => @adapter_settings[:user],
46
- :pass => @adapter_settings[:password],
47
- :host => @adapter_settings[:host],
44
+ vhost = @adapter_settings[:opts][:vhost] || "/"
45
+ @conn ||= AMQP.connect(:user => @adapter_settings[:user],
46
+ :pass => @adapter_settings[:password],
47
+ :host => @adapter_settings[:host],
48
48
  :vhost => vhost)
49
49
  end
50
50
  end
51
-
52
-
51
+
52
+
53
53
  class DirectExchange < BaseExchange
54
54
 
55
55
  def publish(destination, message, options={})
@@ -60,7 +60,7 @@ module RosettaQueue
60
60
  RosettaQueue.logger.info("Publishing to #{destination} :: #{message}")
61
61
  queue.unsubscribe
62
62
  end
63
-
63
+
64
64
  def receive(destination, message_handler)
65
65
  raise AdapterException, "Consumers need to run in an EventMachine 'run' block. Try wrapping them inside the evented consumer manager." unless EM.reactor_running?
66
66
 
@@ -75,7 +75,7 @@ module RosettaQueue
75
75
 
76
76
  def receive_once(destination, options={})
77
77
  raise AdapterException, "Consumers need to run in an EventMachine 'run' block. (e.g., EM.run { RosettaQueue::Consumer.receive }" unless EM.reactor_running?
78
-
78
+
79
79
  queue = channel.queue(destination, @options)
80
80
  ack = @options[:ack]
81
81
  queue.pop(@options) do |header, msg|
@@ -85,8 +85,8 @@ module RosettaQueue
85
85
  end
86
86
  end
87
87
  end
88
-
89
-
88
+
89
+
90
90
  class FanoutExchange < BaseExchange
91
91
  include Fanout
92
92
 
@@ -97,36 +97,36 @@ module RosettaQueue
97
97
  exchange.publish(msg, opts)
98
98
  RosettaQueue.logger.info("Publishing to fanout #{dest} :: #{msg}")
99
99
  end
100
-
100
+
101
101
  def receive(destination, message_handler)
102
102
  raise AdapterException, "Consumers need to run in an EventMachine 'run' block. Try wrapping them inside the evented consumer manager." unless EM.reactor_running?
103
103
 
104
104
  queue = channel.queue("queue_#{self.object_id}")
105
105
  exchange = channel.fanout(fanout_name_for(destination), @options)
106
106
  ack = @options[:ack]
107
-
107
+
108
108
  queue.bind(exchange).subscribe(@options) do |header, msg|
109
109
  RosettaQueue.logger.info("Receiving from #{destination} :: #{msg}")
110
110
  message_handler.on_message(Filters.process_receiving(msg))
111
111
  header.ack if ack
112
112
  end
113
113
  end
114
-
114
+
115
115
  def receive_once(destination, opts={})
116
116
  raise AdapterException, "Consumers need to run in an EventMachine 'run' block. (e.g., EM.run { RosettaQueue::Consumer.receive }" unless EM.reactor_running?
117
117
 
118
118
  queue = channel.queue("queue_#{self.object_id}")
119
119
  exchange = channel.fanout(fanout_name_for(destination), opts)
120
120
  ack = @options[:ack]
121
-
121
+
122
122
  queue.bind(exchange).pop(opts) do |header, msg|
123
123
  RosettaQueue.logger.info("Receiving from #{destination} :: #{msg}")
124
124
  header.ack if ack
125
125
  yield Filters.process_receiving(msg)
126
126
  end
127
127
  end
128
-
128
+
129
129
  end
130
130
  end
131
- end
131
+ end
132
132
  end
@@ -9,7 +9,7 @@ module RosettaQueue
9
9
  class AmqpSynchAdapter < Amqp
10
10
  private
11
11
 
12
- def exchange_strategy_for(destination, options)
12
+ def exchange_strategy_for(destination, options={})
13
13
  case destination
14
14
  when /^fanout\./
15
15
  @exchange ||= SynchExchange::FanoutExchange.new(@adapter_settings, options)
@@ -21,7 +21,7 @@ module RosettaQueue
21
21
  @exchange ||= SynchExchange::DirectExchange.new(@adapter_settings, options)
22
22
  end
23
23
  end
24
- end
24
+ end
25
25
 
26
26
  module SynchExchange
27
27
 
@@ -31,21 +31,27 @@ module RosettaQueue
31
31
  @adapter_settings, @options = adapter_settings, options
32
32
  end
33
33
 
34
- def delete(destination)
35
- conn.queue(destination).delete(@options)
36
- end
34
+ def delete(destination, options={})
35
+ conn.queue(destination).delete(options)
36
+ end
37
+
38
+ def unsubscribe
39
+ @queue.unsubscribe
40
+ conn.stop
41
+ end
37
42
 
38
43
  protected
39
44
 
40
45
  def conn
41
- vhost = @adapter_settings[:opts][:vhost] || "/"
42
- @conn ||= Bunny.new( :user => @adapter_settings[:user],
43
- :pass => @adapter_settings[:password],
44
- :host => @adapter_settings[:host],
46
+ vhost = @adapter_settings[:opts][:vhost] || "/"
47
+ @conn ||= Bunny.new( :user => @adapter_settings[:user],
48
+ :pass => @adapter_settings[:password],
49
+ :host => @adapter_settings[:host],
45
50
  :vhost => vhost)
46
51
  @conn.start unless @conn.status == :connected
47
52
  @conn
48
53
  end
54
+
49
55
  end
50
56
 
51
57
  class DirectExchange < BaseExchange
@@ -54,25 +60,25 @@ module RosettaQueue
54
60
  RosettaQueue.logger.info("Publishing to #{destination} :: #{message}")
55
61
  queue = conn.queue(destination, options)
56
62
  queue.publish(message, options)
57
- queue.unsubscribe
58
- end
63
+ conn.stop
64
+ end
59
65
 
60
66
  def receive(destination, message_handler)
61
- queue = conn.queue(destination, @options)
62
67
  ack = @options[:ack]
63
- queue.subscribe(@options) do |msg|
68
+ @queue = conn.queue(destination, @options)
69
+ @queue.subscribe(@options) do |msg|
64
70
  RosettaQueue.logger.info("Receiving from #{destination} :: #{msg}")
65
71
  message_handler.on_message(Filters.process_receiving(msg))
66
- queue.ack if ack
67
- end
72
+ @queue.ack if ack
73
+ end
68
74
  end
69
75
 
70
- def receive_once(destination)
71
- queue = conn.queue(destination, @options)
72
- ack = @options[:ack]
73
- msg = queue.pop(@options)
76
+ def receive_once(destination, options = {})
77
+ ack = options[:ack]
78
+ @queue = conn.queue(destination, options)
79
+ msg = @queue.pop(options)
74
80
  RosettaQueue.logger.info("Receiving from #{destination} :: #{msg}")
75
- queue.ack if ack
81
+ @queue.ack if ack
76
82
  yield Filters.process_receiving(msg)
77
83
  end
78
84
 
@@ -80,38 +86,38 @@ module RosettaQueue
80
86
 
81
87
  class FanoutExchange < BaseExchange
82
88
  include Fanout
83
-
89
+
84
90
  def publish(destination, message, options={})
85
91
  exchange = conn.exchange(fanout_name_for(destination), options.merge({:type => :fanout}))
86
92
  exchange.publish(message, options)
87
93
  RosettaQueue.logger.info("Publishing to fanout #{destination} :: #{message}")
88
- end
94
+ end
89
95
 
90
96
  def receive(destination, message_handler)
91
- queue = conn.queue("queue_#{self.object_id}", @options)
92
- exchange = conn.exchange(fanout_name_for(destination), @options.merge({:type => :fanout}))
93
- queue.bind(exchange)
94
97
  ack = @options[:ack]
95
-
96
- msg = queue.subscribe(@options) do |msg|
98
+ @queue = conn.queue("queue_#{self.object_id}", @options)
99
+ exchange = conn.exchange(fanout_name_for(destination), @options.merge({:type => :fanout}))
100
+ @queue.bind(exchange)
101
+ @queue.subscribe(@options) do |msg|
97
102
  RosettaQueue.logger.info("Receiving from #{destination} :: #{msg}")
98
103
  message_handler.on_message(Filters.process_receiving(msg))
99
- queue.ack if ack
100
- end
104
+ @queue.ack if ack
105
+ end
101
106
  end
102
107
 
103
108
  def receive_once(destination, options={})
104
- queue = conn.queue("queue_#{self.object_id}", options)
109
+ ack = options[:ack]
110
+ @queue = conn.queue("queue_#{self.object_id}", options)
105
111
  exchange = conn.exchange(fanout_name_for(destination), options.merge({:type => :fanout}))
106
- queue.bind(exchange)
107
- ack = @options[:ack]
108
- msg = queue.pop(@options)
112
+ @queue.bind(exchange)
113
+ msg = @queue.pop(options)
109
114
  RosettaQueue.logger.info("Receiving from #{destination} :: #{msg}")
110
- queue.ack if ack
115
+ @queue.ack if ack
111
116
  yield Filters.process_receiving(msg)
112
117
  end
113
118
 
114
- end
115
- end
119
+ end
120
+
121
+ end
116
122
  end
117
123
  end