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 +8 -8
- data/Gemfile.lock +1 -1
- data/README.md +9 -1
- data/lib/estorm-message-processor/client.rb +9 -0
- data/test/coverage/index.html +1 -1
- data/test/test_estorm.rb +16 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjdjODM3OTA1OGUzMjA3NmViZWUxMjkyYzJhMjdkMzkyM2QxZDQ5Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzRhYWNhYjBmMjRiMzYxYjcyNzJjYWI5YTZiMGQxZWRhZGEzNDhmMw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2Q4ZTZlMWU1YjBmMjU5NDFlMTExZWU0MDFjYzJkNmVmNWNiYzU5MmUwY2Q0
|
10
|
+
MzUxNjgwY2NhNjhjNzNjNzIzNmUwODljYjljOThmZjQ3YTk2NWRhMTU4Nzc5
|
11
|
+
Yzk5MjlmOTg1YWRkOGM0MDE3Mzc0OWYzOTdiYWNmNDYxMDJmNTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjljYjlkZDY0YmU5MjhkNDQ4OWNkOTQ3OWRhZGNjMTg5OWYyMDY1MzlmNDcz
|
14
|
+
OTcwYmNhMGIzOTQxYTk3MTJmZmQzOTgwYTI5Y2E2YmI2ZDlmMzc0ZGZiZmQ2
|
15
|
+
ZjI2Njc2YjA4MDM1MDU0Y2JmZDg1YWNjNDgwZWE3NTBlMDA4Mjc=
|
data/Gemfile.lock
CHANGED
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
|
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
|
data/test/coverage/index.html
CHANGED
@@ -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-
|
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
|
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
|
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
|
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
|
|