amqpop 0.0.1 → 0.0.2
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/lib/amqpop/amqpop.rb +1 -0
- data/lib/amqpop/cli.rb +27 -2
- data/lib/amqpop/version.rb +1 -1
- metadata +4 -4
data/lib/amqpop/amqpop.rb
CHANGED
data/lib/amqpop/cli.rb
CHANGED
@@ -32,7 +32,22 @@ module Amqpop
|
|
32
32
|
vputs "Running #{AMQP::VERSION} version of the AMQP gem."
|
33
33
|
vputs "Connecting to AMQP broker on #{connection_params[:host]} as #{connection_params[:username]}."
|
34
34
|
AMQP.connect(connection_params) do |connection|
|
35
|
-
|
35
|
+
Amqpop.connection = connection
|
36
|
+
connection.on_tcp_connection_loss do |cl, settings|
|
37
|
+
eputs "Connection to AMQP broker lost!"
|
38
|
+
eputs "Waiting 2 seconds to attempt to connect..."
|
39
|
+
cl.reconnect(true, 2)
|
40
|
+
end
|
41
|
+
|
42
|
+
connection.on_open do
|
43
|
+
vputs "Connection established"
|
44
|
+
end
|
45
|
+
|
46
|
+
connection.on_recovery do
|
47
|
+
eputs "Connection reestablished"
|
48
|
+
end
|
49
|
+
|
50
|
+
AMQP::Channel.new(connection, :auto_recovery => true) do |channel|
|
36
51
|
|
37
52
|
channel.on_error do |ch, close|
|
38
53
|
eputs "ERROR: Channel-level exception: #{close.reply_text}, #{close.inspect}"
|
@@ -76,6 +91,8 @@ module Amqpop
|
|
76
91
|
private
|
77
92
|
|
78
93
|
def shutdown
|
94
|
+
eputs "Shutting down"
|
95
|
+
Amqpop.connection.disconnect unless Amqpop.connection.nil?
|
79
96
|
EventMachine.stop
|
80
97
|
@lock.release!
|
81
98
|
exit 0
|
@@ -140,10 +157,17 @@ module Amqpop
|
|
140
157
|
if Amqpop.temp_queue?
|
141
158
|
channel.queue('', :auto_delete => true, :durable => false, :exclusive => true)
|
142
159
|
else
|
143
|
-
|
160
|
+
|
161
|
+
channel.queue(options[:queue_name], :auto_delete => false, :durable => true, :arguments => get_queue_args)
|
144
162
|
end
|
145
163
|
end
|
146
164
|
|
165
|
+
def get_queue_args
|
166
|
+
arguments = {}
|
167
|
+
arguments['x-ha-policy'] = 'all' if options[:mirror]
|
168
|
+
arguments
|
169
|
+
end
|
170
|
+
|
147
171
|
def eputs(msg)
|
148
172
|
Amqpop.eputs msg
|
149
173
|
end
|
@@ -172,6 +196,7 @@ EOS
|
|
172
196
|
opt :queue_name, "Name of the queue on the to connect to, unique if not provided", :type => :string, :default => ''
|
173
197
|
opt :queue_durable, "Is the queue persistant", :default => true
|
174
198
|
opt :queue_auto_delete, "Does the queue remove itself", :default => false
|
199
|
+
opt :mirror, "Does the queue mirror itself to all nodes", :default => false
|
175
200
|
opt :exchange, "Exchange to bind the queue to. Format [name]:<routing_key>, example: logs or weather:usa.*", :type => :string, :short => "-x", :default => ''
|
176
201
|
|
177
202
|
opt :wait, "Amount of time in seconds to wait for more messages to show up. Waits forever if 0", :default => 30
|
data/lib/amqpop/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amqpop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Cherry
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-11-
|
18
|
+
date: 2012-11-30 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: amqp
|