estorm-message-processor 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2EzMDFiYjllMTYwNzc0NGIyN2M1MzQ2MWI5NGYxOWY1OTI1NjNiYw==
4
+ YjdjODM3OTA1OGUzMjA3NmViZWUxMjkyYzJhMjdkMzkyM2QxZDQ5Nw==
5
5
  data.tar.gz: !binary |-
6
- NjE4ZmZhOGQyNTQyZDJmMDc0Y2E0NWZjMDVhMjNjMjA1ZGUzZjM5Yw==
6
+ NzRhYWNhYjBmMjRiMzYxYjcyNzJjYWI5YTZiMGQxZWRhZGEzNDhmMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MWVhYzI5ZjU3MWUyNTAzZGZiNTJmZTcyYjI2MDQ2NzE3NzU4MWNhOGZjZDFk
10
- NmQxYTk3YmZkNTdlMjc4YmM2MGU5MTM4MzhkNjIzYjNhNjlkOTI3ODZmZDRh
11
- OWU3ODY0ODA4N2E4YmQ5Mjc1Yjc4NjMyZjJmYTRmYTBiNTllNWE=
9
+ M2Q4ZTZlMWU1YjBmMjU5NDFlMTExZWU0MDFjYzJkNmVmNWNiYzU5MmUwY2Q0
10
+ MzUxNjgwY2NhNjhjNzNjNzIzNmUwODljYjljOThmZjQ3YTk2NWRhMTU4Nzc5
11
+ Yzk5MjlmOTg1YWRkOGM0MDE3Mzc0OWYzOTdiYWNmNDYxMDJmNTY=
12
12
  data.tar.gz: !binary |-
13
- MTNkYzk4Y2M2NGQxNTExNjZjNWU5NTFiZTZkZGUxNDg0MDFlMGExMTBhMGEz
14
- NDM1YzdkNzhhN2EyMGY4NmJlZGYxMjQ4YzIzMzZiZjVjOGJlMjlhNDQxNjc3
15
- N2MzMmJlMmJkZmI4M2M5ZmMwNDZmN2VjZDYwZjA0ZjgzNGE3YTY=
13
+ ZjljYjlkZDY0YmU5MjhkNDQ4OWNkOTQ3OWRhZGNjMTg5OWYyMDY1MzlmNDcz
14
+ OTcwYmNhMGIzOTQxYTk3MTJmZmQzOTgwYTI5Y2E2YmI2ZDlmMzc0ZGZiZmQ2
15
+ ZjI2Njc2YjA4MDM1MDU0Y2JmZDg1YWNjNDgwZWE3NTBlMDA4Mjc=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- estorm-message-processor (0.1.1)
4
+ estorm-message-processor (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -11,7 +11,7 @@ Simple gem to use in rails apps for AMQP inclusiong. Send a hash via AMQP and th
11
11
  Usage
12
12
  =======
13
13
 
14
- pull in the normal files for ruby. Everytime a message is received with 'command' => "sendtemplates" delegate to that callback So add more delete_routings and you will be able to handle multiple commands
14
+ pull in the normal files for ruby. Everytime a message is received with 'command' => "sendtemplates" delegate to that callback So add more delegate_routings and you will be able to handle multiple commands
15
15
 
16
16
  ## Setup delegate processor
17
17
  This is the callback processor
@@ -37,3 +37,11 @@ This is the callback processor
37
37
  puts "Exception in Message Processor: #{ex} at #{ex.backtrace.join("\n")}"
38
38
  end
39
39
 
40
+ # send a message using the client
41
+ Use the client to send a message to the delegate processor (background task)
42
+ def bunny_send
43
+ cmdhash={'command'=>'sendtemplates', 'promotion'=>self.id.to_s}
44
+ puts "----> to system [x] sending #{cmdhash.inspect}"
45
+ bunny=EstormMessageProcessor::Client.new
46
+ bunny.bunny_send(AMQPURL,Rails.env.production?,CONTACT_MESSAGE,cmdhash)
47
+ end
@@ -23,6 +23,15 @@ module EstormMessageProcessor
23
23
  #cmdhash={'command'=>'sendtemplates', 'promotion'=>self.id.to_s}
24
24
  channel.default_exchange.publish(cmdhash.to_yaml, :routing_key => queue.name)
25
25
  @conn.close
26
+ end
27
+ def connection
28
+ @conn
26
29
  end
30
+ def bunny_send_no_close(url,flag,queuename,cmdhash)
31
+ @conn,channel=setup_bunny(url,flag)
32
+ queue = channel.queue(queuename)
33
+ #cmdhash={'command'=>'sendtemplates', 'promotion'=>self.id.to_s}
34
+ channel.default_exchange.publish(cmdhash.to_yaml, :routing_key => queue.name)
35
+ end
27
36
  end
28
37
  end
@@ -14,7 +14,7 @@
14
14
  <img src="./assets/0.7.1/loading.gif" alt="loading"/>
15
15
  </div>
16
16
  <div id="wrapper" style="display:none;">
17
- <div class="timestamp">Generated <abbr class="timeago" title="2013-10-12T12:36:00+08:00">2013-10-12T12:36:00+08:00</abbr></div>
17
+ <div class="timestamp">Generated <abbr class="timeago" title="2013-10-12T21:32:57+08:00">2013-10-12T21:32:57+08:00</abbr></div>
18
18
  <ul class="group_tabs"></ul>
19
19
 
20
20
  <div id="content">
data/test/test_estorm.rb CHANGED
@@ -33,10 +33,11 @@ class EstormMessageProcessTest < Minitest::Test
33
33
  end
34
34
 
35
35
  def test_startup
36
+ puts "test startup"
36
37
  config={:url => 'fakeurl',:connecturlflag=> false,:queuename => 'testqueue', :blocking => true}
37
38
  Thread.new {
38
39
  @f.start(config) }
39
- sleep(15)
40
+ sleep 6
40
41
  @f.tear_down_bunny
41
42
  assert true,"should get here"
42
43
  end
@@ -49,11 +50,12 @@ class EstormMessageProcessTest < Minitest::Test
49
50
  assert loaded['test']==fred['test'],"values should be smae"
50
51
  end
51
52
  def test_message
53
+ puts "test message"
52
54
  assert MessageFlag.flag==false, "should be flase #{MessageFlag.inspect}"
53
55
  config={:url => 'fakeurl',:connecturlflag=> false,:queuename => 'testqueue', :blocking => true}
54
56
  Thread.new {
55
57
  @f.start(config) }
56
- sleep(20)
58
+ sleep 6
57
59
  puts "after start in test message"
58
60
  Thread.new {
59
61
 
@@ -64,11 +66,22 @@ class EstormMessageProcessTest < Minitest::Test
64
66
  puts "after bunny send"
65
67
  }
66
68
  puts "after client in test message"
67
- sleep 5
69
+ sleep 3
68
70
  assert MessageFlag.flag==true, "should receive message and set temp #{MessageFlag.inspect}"
69
71
  @f.tear_down_bunny
70
72
 
71
73
  end
74
+ def test_client
75
+ cmdhash={'command'=>'testdelegate', 'promotion'=>2.to_s}
76
+ puts "----> to system [x] sending #{cmdhash.inspect}"
77
+ config={:url => 'fakeurl',:connecturlflag=> false,:queuename => 'testqueue', :blocking => true}
78
+ bunny=EstormMessageProcessor::Client.new
79
+ assert bunny!=nil, "bunny should not be nil"
80
+ bunny.bunny_send_no_close(config[:url],config[:connnecturlflag],config[:queuename],cmdhash)
81
+ assert bunny.connection!=nil, "should be ok"
82
+ res=bunny.connection.close
83
+ assert res=='closed'.to_sym, "should be closed: #{res.inspect}"
84
+ end
72
85
 
73
86
 
74
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: estorm-message-processor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Sproule