activemessaging 0.13.1 → 0.13.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/activemessaging/adapters/asqs.rb +23 -23
- data/lib/activemessaging/version.rb +1 -1
- metadata +4 -4
@@ -25,7 +25,7 @@ module ActiveMessaging
|
|
25
25
|
|
26
26
|
#configurable params
|
27
27
|
attr_accessor :reconnect_delay, :access_key_id, :secret_access_key, :aws_version, :content_type, :host, :port, :poll_interval, :cache_queue_list, :max_message_size
|
28
|
-
|
28
|
+
|
29
29
|
#generic init method needed by a13g
|
30
30
|
def initialize cfg
|
31
31
|
raise "Must specify a access_key_id" if (cfg[:access_key_id].nil? || cfg[:access_key_id].empty?)
|
@@ -49,7 +49,7 @@ module ActiveMessaging
|
|
49
49
|
|
50
50
|
@cache_queue_list = cfg[:cache_queue_list].nil? ? true : cfg[:cache_queue_list]
|
51
51
|
@reliable = cfg[:reliable].nil? ? true : cfg[:reliable]
|
52
|
-
|
52
|
+
|
53
53
|
#initialize the subscriptions and queues
|
54
54
|
@subscriptions = {}
|
55
55
|
@queues_by_priority = {}
|
@@ -132,7 +132,7 @@ module ActiveMessaging
|
|
132
132
|
|
133
133
|
next if queue.nil? || subscription.nil?
|
134
134
|
messages = retrieve_messsages(queue, 1, subscription.headers[:visibility_timeout])
|
135
|
-
|
135
|
+
|
136
136
|
if (messages && !messages.empty?)
|
137
137
|
message = messages[0]
|
138
138
|
end
|
@@ -179,14 +179,14 @@ module ActiveMessaging
|
|
179
179
|
def unreceive message, headers={}
|
180
180
|
return true
|
181
181
|
end
|
182
|
-
|
182
|
+
|
183
183
|
protected
|
184
|
-
|
184
|
+
|
185
185
|
def create_queue(name)
|
186
186
|
validate_new_queue name
|
187
187
|
response = make_request('CreateQueue', nil, {'QueueName'=>name})
|
188
188
|
add_queue(response.get_text("//QueueUrl")) unless response.nil?
|
189
|
-
end
|
189
|
+
end
|
190
190
|
|
191
191
|
def delete_queue queue
|
192
192
|
validate_queue queue
|
@@ -199,7 +199,7 @@ module ActiveMessaging
|
|
199
199
|
response = make_request('ListQueues', nil, params)
|
200
200
|
response.nil? ? [] : response.nodes("//QueueUrl").collect{ |n| add_queue(n.text) }
|
201
201
|
end
|
202
|
-
|
202
|
+
|
203
203
|
def get_queue_attributes(queue, attribute='All')
|
204
204
|
validate_get_queue_attribute(attribute)
|
205
205
|
params = {'AttributeName'=>attribute}
|
@@ -247,15 +247,15 @@ module ActiveMessaging
|
|
247
247
|
response = make_request('ReceiveMessage', "#{queue.queue_url}", params)
|
248
248
|
response.nodes("//Message").collect{ |n| Message.from_element n, response, queue } unless response.nil?
|
249
249
|
end
|
250
|
-
|
250
|
+
|
251
251
|
def delete_message message
|
252
252
|
response = make_request('DeleteMessage', "#{message.queue.queue_url}", {'ReceiptHandle'=>message.receipt_handle})
|
253
253
|
end
|
254
254
|
|
255
255
|
def make_request(action, url=nil, params = {})
|
256
256
|
# puts "make_request a=#{action} u=#{url} p=#{params}"
|
257
|
-
url ||= @aws_url
|
258
|
-
|
257
|
+
url ||= (@aws_url + "/")
|
258
|
+
|
259
259
|
# Add Actions
|
260
260
|
params['Action'] = action
|
261
261
|
params['Version'] = @aws_version
|
@@ -312,9 +312,9 @@ module ActiveMessaging
|
|
312
312
|
raise response.errors if (response && response.errors?)
|
313
313
|
response
|
314
314
|
end
|
315
|
-
|
315
|
+
|
316
316
|
private
|
317
|
-
|
317
|
+
|
318
318
|
# internal data structure methods
|
319
319
|
def add_queue(url)
|
320
320
|
q = Queue.from_url url
|
@@ -379,14 +379,14 @@ module ActiveMessaging
|
|
379
379
|
|
380
380
|
class SQSResponse
|
381
381
|
attr_accessor :headers, :doc, :http_response
|
382
|
-
|
382
|
+
|
383
383
|
def initialize response
|
384
384
|
# puts "response.body = #{response.body}"
|
385
385
|
@http_response = response
|
386
386
|
@headers = response.to_hash()
|
387
387
|
@doc = REXML::Document.new(response.body)
|
388
388
|
end
|
389
|
-
|
389
|
+
|
390
390
|
def message_type
|
391
391
|
return doc ? doc.root.name : ''
|
392
392
|
end
|
@@ -409,16 +409,16 @@ module ActiveMessaging
|
|
409
409
|
|
410
410
|
return msg
|
411
411
|
end
|
412
|
-
|
412
|
+
|
413
413
|
def get_text(xpath,default='')
|
414
414
|
e = REXML::XPath.first( doc, xpath)
|
415
415
|
e.nil? ? default : e.text
|
416
416
|
end
|
417
|
-
|
417
|
+
|
418
418
|
def each_node(xp)
|
419
419
|
REXML::XPath.each(doc.root, xp) {|n| yield n}
|
420
420
|
end
|
421
|
-
|
421
|
+
|
422
422
|
def nodes(xp)
|
423
423
|
doc.elements.to_a(xp)
|
424
424
|
end
|
@@ -426,12 +426,12 @@ module ActiveMessaging
|
|
426
426
|
|
427
427
|
class Subscription
|
428
428
|
attr_accessor :destination, :headers, :count, :priority
|
429
|
-
|
429
|
+
|
430
430
|
def initialize(destination, headers={}, count=1)
|
431
431
|
@priority = headers.delete(:priority) || 1001
|
432
432
|
@destination, @headers, @count = destination, headers, count
|
433
433
|
end
|
434
|
-
|
434
|
+
|
435
435
|
def add
|
436
436
|
@count += 1
|
437
437
|
end
|
@@ -448,7 +448,7 @@ module ActiveMessaging
|
|
448
448
|
u = URI.parse(url)
|
449
449
|
name = u.path.gsub(/\//, "")
|
450
450
|
domain = u.host
|
451
|
-
return Queue.new(name,domain)
|
451
|
+
return Queue.new(name,domain)
|
452
452
|
end
|
453
453
|
|
454
454
|
def queue_url
|
@@ -467,11 +467,11 @@ module ActiveMessaging
|
|
467
467
|
# based on stomp message, has pointer to the SQSResponseObject
|
468
468
|
class Message < ActiveMessaging::BaseMessage
|
469
469
|
attr_accessor :response, :queue, :md5_of_body, :receipt_handle
|
470
|
-
|
470
|
+
|
471
471
|
def self.from_element e, response, queue
|
472
472
|
Message.new(e.elements['Body'].text, response.headers, e.elements['MessageId'].text, e.elements['MD5OfBody'].text, e.elements['ReceiptHandle'].text, response, queue)
|
473
473
|
end
|
474
|
-
|
474
|
+
|
475
475
|
def initialize body, headers, id, md5_of_body, receipt_handle, response, queue
|
476
476
|
super(body, id, headers, queue.name)
|
477
477
|
@md5_of_body, @receipt_handle, @response, @queue = md5_of_body, receipt_handle, response, queue
|
@@ -481,7 +481,7 @@ module ActiveMessaging
|
|
481
481
|
"<AmazonSQS::Message id='#{id}' body='#{body}' headers='#{headers.inspect}' response='#{response}'>"
|
482
482
|
end
|
483
483
|
end
|
484
|
-
|
484
|
+
|
485
485
|
end
|
486
486
|
end
|
487
487
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemessaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -16,7 +16,7 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: exe
|
18
18
|
cert_chain: []
|
19
|
-
date:
|
19
|
+
date: 2018-03-07 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: bundler
|
@@ -213,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
213
|
version: '0'
|
214
214
|
segments:
|
215
215
|
- 0
|
216
|
-
hash: -
|
216
|
+
hash: -3200962007466934586
|
217
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
218
|
none: false
|
219
219
|
requirements:
|
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
version: '0'
|
223
223
|
segments:
|
224
224
|
- 0
|
225
|
-
hash: -
|
225
|
+
hash: -3200962007466934586
|
226
226
|
requirements: []
|
227
227
|
rubyforge_project:
|
228
228
|
rubygems_version: 1.8.23.2
|