rabbit-wq 1.3.0 → 1.4.0
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.
- checksums.yaml +4 -4
- data/README.md +14 -3
- data/lib/rabbit_wq/configuration.rb +9 -3
- data/lib/rabbit_wq/queues.rb +0 -10
- data/lib/rabbit_wq/server.rb +5 -5
- data/lib/rabbit_wq/version.rb +1 -1
- data/lib/rabbit_wq/work.rb +23 -30
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8e86ae9f34e0920dceda5699c13b63363a82d38
|
4
|
+
data.tar.gz: 6af20f31ad5f3a8f4cded189d805f74df5e81fb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
"
|
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
|
-
#####
|
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
|
-
|
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
|
73
|
-
@
|
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
|
data/lib/rabbit_wq/queues.rb
CHANGED
@@ -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
|
data/lib/rabbit_wq/server.rb
CHANGED
@@ -39,10 +39,10 @@ module RabbitWQ
|
|
39
39
|
config.work_exchange, durable: true )
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
@
|
44
|
-
|
45
|
-
|
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 =
|
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
|
data/lib/rabbit_wq/version.rb
CHANGED
data/lib/rabbit_wq/work.rb
CHANGED
@@ -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( "#{
|
19
|
+
delay_x = channel.direct( "#{config.delayed_exchange_prefix}-#{delay}ms", durable: true )
|
18
20
|
|
19
|
-
work_x = channel.send(
|
20
|
-
|
21
|
+
work_x = channel.send( config.work_exchange_type,
|
22
|
+
config.work_exchange,
|
21
23
|
durable: true )
|
22
24
|
|
23
|
-
channel.queue( "#{
|
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:
|
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,
|
38
|
-
|
39
|
-
|
40
|
-
|
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(
|
48
|
+
error_q = channel.queue( config.error_queue, durable: true )
|
47
49
|
error_q.publish( payload, durable: true,
|
48
|
-
content_type:
|
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(
|
57
|
-
|
58
|
+
exchange = channel.send( config.work_exchange_type,
|
59
|
+
config.work_exchange,
|
58
60
|
durable: true )
|
59
61
|
|
60
|
-
channel.queue(
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
83
|
-
|
84
|
-
|
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.
|
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-
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|