rabbit-wq 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cc6f0e1818ec8018d83f187a1b893286577dfc5
4
- data.tar.gz: 7e09ea7946c1079478c86021062cdda8bcb18773
3
+ metadata.gz: f8e86ae9f34e0920dceda5699c13b63363a82d38
4
+ data.tar.gz: 6af20f31ad5f3a8f4cded189d805f74df5e81fb5
5
5
  SHA512:
6
- metadata.gz: ce94b748c73d75c32e5ae2456d34e25a5e6139840604d9c2cf0760d3f8e7c4814832f83399e26bf6eee91e7574c5c006f3226f8c92daef83a8e85e21ff7f6c36
7
- data.tar.gz: 8168b5fcaac9210163bb0bc58a32bf8fa6365e4e1fd1009c0cd19d38f2190f577bd0f457875761a9aae398d4a2e263c0a1a2e3c4f891273176cb91956991aa2f
6
+ metadata.gz: 448e60e96a6bd5a3f578ffe70312fc013d913dead47bcb203b652b37580f50735278b33076cd48900631b0fd27bc706ffab4147b6655a5923ee1c26477b637a8
7
+ data.tar.gz: b62f2e1b0e71089eb1129de9abf010e86c73e8ef8353e866af423a96ed0ee4e6b4e90c980968930ce36832c76a5205777bcb3a6a9e19ac0180ceba3d66620d5e
data/README.md CHANGED
@@ -138,6 +138,13 @@ do not have to provide a refrence to self in this case.
138
138
 
139
139
  The RabbitWQ loggers provide the following log levels: debug, info, warn, error and fatal.
140
140
 
141
+ ### Work Publish vs. Subscribe Queue
142
+
143
+ Quite often the work publish and subscribe queues are the same queue. However, certain use cases require a seprarate work publish
144
+ and subscribe queue. For instance, when you use te RabbitMQ shovel plugin to effectively create a distributed queue, you may want
145
+ to publish to a local queue that is shoveled to a central work queue, where the subscriber resides and performs the actual work.
146
+
147
+
141
148
  ### Configuration File
142
149
 
143
150
  The RabbitWQ configuration file uses JSON syntax. The default location for the configuration file is /var/run/rabbit-wq/rabbit-wq.conf
@@ -156,7 +163,8 @@ Here is an example configuration file with each option's default value:
156
163
  "work_exchange_type": "fanout",
157
164
  "work_log_level": "info",
158
165
  "work_log_path": "/var/log/rabbit-wq/rabbit-wq-work.log",
159
- "work_queue": "work"
166
+ "work_publish_queue": "work"
167
+ "work_subscribe_queue": "work"
160
168
  }
161
169
 
162
170
  #### Options
@@ -194,8 +202,11 @@ The log level of the worker logger. Defaults to info.
194
202
  #####work_log_path
195
203
  The path the worker logger will log to. Defaults to /var/log/rabbit-wq/rabbit-wq-work.log.
196
204
 
197
- #####work_queue
198
- The name of the work queue. Defaults to work.
205
+ #####work_publish_queue
206
+ The name of the work queue to publish to. Defaults to work.
207
+
208
+ #####work_subscribe_queue
209
+ The name of the work queue to subscribe to. Defaults to work.
199
210
 
200
211
 
201
212
  ### Command Line Interface
@@ -16,7 +16,8 @@ module RabbitWQ
16
16
  work_exchange_type
17
17
  work_log_level
18
18
  work_log_path
19
- work_queue
19
+ work_publish_queue
20
+ work_subscribe_queue
20
21
  )
21
22
  end
22
23
 
@@ -69,9 +70,14 @@ module RabbitWQ
69
70
  @work_log_path || '/var/log/rabbit-wq/rabbit-wq-work.log'
70
71
  end
71
72
 
72
- def work_queue
73
- @work_queue || 'work'
73
+ def work_publish_queue
74
+ @work_publish_queue || 'work'
75
+ end
76
+
77
+ def work_subscribe_queue
78
+ @work_subscribe_queue || 'work'
74
79
  end
75
80
 
76
81
  end
82
+
77
83
  end
@@ -15,15 +15,5 @@ module RabbitWQ
15
15
  end
16
16
  end
17
17
 
18
- #def work_exchange
19
- #@work_exchange ||= channel.direct( RabbitWQ.configuration.work_exchange, durable: true )
20
- #end
21
-
22
- #def work_queue
23
- #@work_queue ||= channel.queue( RabbitWQ.configuration.work_queue,
24
- #durable: true ).
25
- #bind( work_exchange )
26
- #end
27
-
28
18
  end
29
19
  end
@@ -39,10 +39,10 @@ module RabbitWQ
39
39
  config.work_exchange, durable: true )
40
40
  end
41
41
 
42
- def work_queue
43
- @work_queue ||= channel.queue( config.work_queue,
44
- durable: true ).
45
- bind( work_exchange )
42
+ def work_subscribe_queue
43
+ @work_subscribe_queue ||= channel.queue( config.work_subscribe_queue,
44
+ durable: true ).
45
+ bind( work_exchange )
46
46
  end
47
47
 
48
48
  def pool
@@ -54,7 +54,7 @@ module RabbitWQ
54
54
  Celluloid::Actor[:message_handler] = MessageHandler.new
55
55
  end
56
56
 
57
- @work_consumer = work_queue.subscribe( manual_ack: true ) do |delivery_info, metadata, payload|
57
+ @work_consumer = work_subscribe_queue.subscribe( manual_ack: true ) do |delivery_info, metadata, payload|
58
58
  info "LISTENER RECEIVED #{payload}"
59
59
 
60
60
  if threads > 1
@@ -1,3 +1,3 @@
1
1
  module RabbitWQ
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -3,6 +3,8 @@ require 'bunny'
3
3
  module RabbitWQ
4
4
  module Work
5
5
 
6
+ YAML_MIMETYPE = 'application/yaml'
7
+
6
8
  def self.enqueue( worker, options={} )
7
9
  payload = worker.to_yaml
8
10
  enqueue_payload( payload, options )
@@ -14,38 +16,38 @@ module RabbitWQ
14
16
 
15
17
  if delay
16
18
  with_channel do |channel|
17
- delay_x = channel.direct( "#{RabbitWQ.configuration.delayed_exchange_prefix}-#{delay}ms", durable: true )
19
+ delay_x = channel.direct( "#{config.delayed_exchange_prefix}-#{delay}ms", durable: true )
18
20
 
19
- work_x = channel.send( RabbitWQ.configuration.work_exchange_type,
20
- RabbitWQ.configuration.work_exchange,
21
+ work_x = channel.send( config.work_exchange_type,
22
+ config.work_exchange,
21
23
  durable: true )
22
24
 
23
- channel.queue( "#{RabbitWQ.configuration.delayed_queue_prefix}-#{delay}ms",
25
+ channel.queue( "#{config.delayed_queue_prefix}-#{delay}ms",
24
26
  durable: true,
25
27
  arguments: { "x-dead-letter-exchange" => work_x.name,
26
28
  "x-message-ttl" => delay } ).
27
29
  bind( delay_x )
28
30
 
29
31
  delay_x.publish( payload, durable: true,
30
- content_type: 'application/yaml',
32
+ content_type: YAML_MIMETYPE,
31
33
  headers: options )
32
34
  end
33
35
 
34
36
  return
35
37
  end
36
38
 
37
- with_work_exchange do |work_x, work_q|
38
- work_x.publish( payload, durable: true,
39
- content_type: 'application/yaml',
40
- headers: options )
39
+ with_work_exchange do |work_x, work_pub_q, work_sub_q|
40
+ work_pub_q.publish( payload, durable: true,
41
+ content_type: YAML_MIMETYPE,
42
+ headers: options )
41
43
  end
42
44
  end
43
45
 
44
46
  def self.enqueue_error_payload( payload, options={} )
45
47
  with_channel do |channel|
46
- error_q = channel.queue( RabbitWQ.configuration.error_queue, durable: true )
48
+ error_q = channel.queue( config.error_queue, durable: true )
47
49
  error_q.publish( payload, durable: true,
48
- content_type: 'application/yaml',
50
+ content_type: YAML_MIMETYPE,
49
51
  headers: options )
50
52
  end
51
53
  end
@@ -53,14 +55,15 @@ module RabbitWQ
53
55
  def self.with_work_exchange
54
56
  with_channel do |channel|
55
57
  begin
56
- exchange = channel.send( RabbitWQ.configuration.work_exchange_type,
57
- RabbitWQ.configuration.work_exchange,
58
+ exchange = channel.send( config.work_exchange_type,
59
+ config.work_exchange,
58
60
  durable: true )
59
61
 
60
- channel.queue( RabbitWQ.configuration.work_queue, durable: true ).tap do |q|
61
- q.bind( exchange )
62
- yield exchange, q
63
- end
62
+ work_pub_q = channel.queue( config.work_publish_queue, durable: true )
63
+ work_sub_q = channel.queue( config.work_subscribe_queue, durable: true )
64
+ work_sub_q.bind( exchange )
65
+
66
+ yield exchange, work_pub_q, work_sub_q
64
67
  ensure
65
68
  end
66
69
  end
@@ -79,19 +82,9 @@ module RabbitWQ
79
82
  end
80
83
  end
81
84
 
82
- #def self.with_exchange
83
- #Bunny.new.tap do |b|
84
- #b.start
85
- #begin
86
- #b.create_channel.tap do |c|
87
- #queue = c.queue( 'replication', durable: true )
88
- #yield c.default_exchange, queue.name
89
- #end
90
- #ensure
91
- #b.stop
92
- #end
93
- #end
94
- #end
85
+ def self.config
86
+ RabbitWQ.configuration
87
+ end
95
88
 
96
89
  end
97
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbit-wq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - C. Jason Harrelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-10 00:00:00.000000000 Z
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler