rflow-components-amqp 1.0.1 → 1.1.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: f4205628f5286b692cf8fd1fe5bddf5a7d946a61
4
- data.tar.gz: f7fff9bf0d0e968fdb3d59837c836665653d94de
3
+ metadata.gz: 72ceb11aa78801df45de0137699f3b72d2a16c52
4
+ data.tar.gz: 92994ff04ab11f0612033b81517940bec8ec486e
5
5
  SHA512:
6
- metadata.gz: 65c53ef866da9fea9966472983954e8a693c222be451e33917d6212cda61f6de8895dfb3331f7a888e8229ae750cef4c75c5018c81a71717d58fad3da5f7df43
7
- data.tar.gz: dc54307bc5c83b029df8f64f0661a917e021aad6a7d7f963360ae51166d2447b7d3aa4d40f719cebaf20320816805763547da80e4e5f8b1ed1bf2ba8552cf807
6
+ metadata.gz: f907324d9cb0c7bd0d980670f32a0e3b70391aed7b9601b47f7fba1599108aaaba5392b422c9dce5db537d7724f1d91542a105cb0a8a77f029d0cf00da102180
7
+ data.tar.gz: 319b3c6b80cc890bfad382e40d5ac7f430d0e97416dd337402399f7e0aead7e702e973a30f422f829624b372023bfbe48900ddcca2c85393f1114c1ee16f6168
data/.travis.yml CHANGED
@@ -8,6 +8,7 @@ rvm:
8
8
  before_install:
9
9
  - sudo apt-get install libtool autoconf automake uuid-dev build-essential
10
10
  - wget http://download.zeromq.org/zeromq-3.2.4.tar.gz && tar zxvf zeromq-3.2.4.tar.gz && cd zeromq-3.2.4 && ./configure && make && sudo make install && cd ..
11
+ - gem update bundler
11
12
  # Only has 4.0.4, need 3.2 version due to old em-zeromq
12
13
  # - sudo add-apt-repository -y ppa:chris-lea/zeromq
13
14
  # - sudo apt-get update
@@ -1,6 +1,7 @@
1
1
  require 'eventmachine'
2
2
  require 'amqp'
3
3
  require 'rflow'
4
+ require 'time'
4
5
 
5
6
  class RFlow
6
7
  module Components
@@ -11,6 +12,7 @@ class RFlow
11
12
  class Subscriber < RFlow::Component
12
13
  output_port :amqp_port
13
14
  output_port :raw_port
15
+ output_port :log_port
14
16
 
15
17
  attr_accessor :config, :queue_config
16
18
 
@@ -20,6 +22,7 @@ class RFlow
20
22
  'username' => 'guest',
21
23
  'password' => 'guest',
22
24
  'vhost' => '/',
25
+ 'reconnect_interval' => 20,
23
26
 
24
27
  'queue_name' => 'asdf',
25
28
  'queue_passive' => false,
@@ -33,6 +36,7 @@ class RFlow
33
36
  def configure!(config)
34
37
  @config = DEFAULT_CONFIG.merge config
35
38
  @config['port'] = @config['port'].to_i
39
+ @config['reconnect_interval'] = @config['reconnect_interval'].to_i
36
40
 
37
41
  ['durable', 'passive', 'exclusive', 'auto_delete'].each do |opt|
38
42
  @config["queue_#{opt}"] = to_boolean(@config["queue_#{opt}"])
@@ -48,18 +52,32 @@ class RFlow
48
52
  end
49
53
 
50
54
  def run!
51
- ::AMQP.connect(:host => @config['server'], :port => @config['port'], :vhost => @config['vhost'], :username => @config['username'], :password => @config['password']) do |conn|
55
+ ::AMQP.connect(:host => @config['server'], :port => @config['port'], :vhost => @config['vhost'],
56
+ :username => @config['username'], :password => @config['password']) do |conn|
52
57
  @amqp_connection = conn
58
+ RFlow.logger.info 'Connected to AMQP server...'
59
+
60
+ conn.on_disconnection do
61
+ RFlow.logger.error 'AMQP disconnected. Reconnecting...'
62
+ log_port.send_message(RFlow::Message.new('RFlow::Message::Data::Log').tap do |m|
63
+ m.data.timestamp = Integer(Time.now.to_f * 1000) # ms since epoch
64
+ m.data.level = 'INFO'
65
+ m.data.text = "AMQP disconnected. Reconnecting in #{@config['reconnect_interval']} seconds."
66
+ end)
67
+
68
+ EventMachine::Timer.new(@config['reconnect_interval']) { run! }
69
+ end
53
70
 
54
71
  ::AMQP::Channel.new(@amqp_connection) do |channel|
55
72
  @amqp_channel = channel
73
+ channel.auto_recovery = true
56
74
  @amqp_exchange = @amqp_channel.topic
57
75
 
58
76
  ::AMQP::Queue.new(@amqp_channel, @config['queue_name'], @queue_config) do |queue|
59
77
  @amqp_queue = queue
60
78
  @amqp_queue.bind(@amqp_exchange, :routing_key => @config['binding_pattern']).subscribe(:ack => true) do |header, payload|
61
79
  RFlow.logger.debug { "#{name}: AMQP message received" }
62
- processing_event = RFlow::Message::ProcessingEvent.new(instance_uuid, Time.now.utc).tap do |e|
80
+ processing_event = RFlow::Message::ProcessingEvent.new(uuid, Time.now.utc).tap do |e|
63
81
  e.completed_at = Time.now.utc
64
82
  end
65
83
 
@@ -1,7 +1,7 @@
1
1
  class RFlow
2
2
  module Components
3
3
  module AMQP
4
- VERSION = "1.0.1"
4
+ VERSION = "1.1.0"
5
5
  end
6
6
  end
7
7
  end
@@ -21,8 +21,9 @@ Gem::Specification.new do |s|
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
22
  s.require_paths = ["lib"]
23
23
 
24
- s.add_dependency 'rflow', '~> 1.0.0'
24
+ s.add_dependency 'rflow', '~> 1.1', '>= 1.1.1'
25
25
  s.add_dependency 'amqp', '>= 0.8.0'
26
+ s.add_dependency 'amq-protocol', '< 2.0' # until Ruby 2.0 compatibility is achieved
26
27
 
27
28
  s.add_development_dependency 'rspec', '~> 3.0'
28
29
  s.add_development_dependency 'rspec-collection_matchers', '~> 1.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rflow-components-amqp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael L. Artz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-17 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rflow
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: '1.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.1.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: 1.0.0
29
+ version: '1.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: amqp
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +44,20 @@ dependencies:
38
44
  - - ">="
39
45
  - !ruby/object:Gem::Version
40
46
  version: 0.8.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: amq-protocol
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '2.0'
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: rspec
43
63
  requirement: !ruby/object:Gem::Requirement
@@ -126,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
146
  version: '0'
127
147
  requirements: []
128
148
  rubyforge_project: rflow-components-amqp
129
- rubygems_version: 2.3.0
149
+ rubygems_version: 2.2.2
130
150
  signing_key:
131
151
  specification_version: 4
132
152
  summary: AMQP publisher and subscriber component for the RFlow FBP framework