stormmq-client 0.0.4 → 0.0.5
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/CHANGELOG +13 -0
- data/bin/stormmq-amqp-echo-test +35 -36
- data/lib/stormmq/amqp.rb +16 -65
- data/lib/stormmq/rest.rb +2 -1
- data/lib/stormmq/utils.rb +0 -3
- data/lib/stormmq/version.rb +3 -0
- metadata +6 -4
data/CHANGELOG
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
0.0.5
|
2
|
+
|
3
|
+
* Re-implemented our AMQP client wrapper so we now use the Bunny
|
4
|
+
client for RabbitMQ. Bunny is a synchronous client built upon
|
5
|
+
QRack. Our wrapper provides simple convenience methods for
|
6
|
+
obtaining a client instance which is configured with the proper
|
7
|
+
vhost based on the StormMQ companyName, systemName and
|
8
|
+
environmentName parameters. Our wrapper returns an instance of
|
9
|
+
the Bunny client.
|
10
|
+
|
11
|
+
See: http://github.com/celldee/bunny for details.
|
12
|
+
|
13
|
+
0.0.4 - Initial Public Release.
|
data/bin/stormmq-amqp-echo-test
CHANGED
@@ -65,46 +65,45 @@ class StormMQ::Application::AMQPEchoTest < StormMQ::Application
|
|
65
65
|
|
66
66
|
def main
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
queue
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
puts "
|
100
|
-
|
101
|
-
puts msg
|
102
|
-
puts msg == 'hello world' ? 'Succeeded' : 'Failed'
|
103
|
-
connection.close{ EM.stop_event_loop }
|
68
|
+
retval = nil
|
69
|
+
|
70
|
+
client_options = {
|
71
|
+
:user => opt.amqpUser,
|
72
|
+
:pass => opt.amqpPassword,
|
73
|
+
:company => opt.company,
|
74
|
+
:system => opt.system,
|
75
|
+
:environment => opt.environment,
|
76
|
+
:host => opt.host,
|
77
|
+
:port => opt.port,
|
78
|
+
:logging => opt['--debug']
|
79
|
+
}
|
80
|
+
|
81
|
+
test_message = 'Hello World!'
|
82
|
+
|
83
|
+
puts "setting up client and connection"
|
84
|
+
StormMQ::AMQPClient.run(client_options) do |client|
|
85
|
+
|
86
|
+
puts "declaring a queue"
|
87
|
+
queue = client.queue('test1')
|
88
|
+
|
89
|
+
puts "publishing test message '#{test_message}'"
|
90
|
+
queue.publish(test_message)
|
91
|
+
|
92
|
+
puts "Receiving message from the queue"
|
93
|
+
msg = queue.pop[:payload]
|
94
|
+
|
95
|
+
if msg == test_message
|
96
|
+
puts "\nSUCESS: received test message '#{msg}'"
|
97
|
+
retval = 0
|
98
|
+
else
|
99
|
+
puts "\nFAILURE: expected test message, but got '#{msg}' instead"
|
100
|
+
retval = 1
|
104
101
|
end
|
105
102
|
|
106
103
|
end
|
107
104
|
|
105
|
+
exit(retval)
|
106
|
+
|
108
107
|
end
|
109
108
|
|
110
109
|
def man
|
data/lib/stormmq/amqp.rb
CHANGED
@@ -6,78 +6,29 @@
|
|
6
6
|
# for terms of use and redistribution.
|
7
7
|
#++
|
8
8
|
|
9
|
-
require 'mq'
|
10
|
-
require 'pp'
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
module AMQPClientImplementation
|
15
|
-
|
16
|
-
VERSION = '0.0.4'
|
17
|
-
|
18
|
-
def process_frame frame
|
19
|
-
if mq = channels[frame.channel]
|
20
|
-
mq.process_frame(frame)
|
21
|
-
return
|
22
|
-
end
|
23
|
-
|
24
|
-
case frame
|
25
|
-
when Frame::Method
|
26
|
-
case method = frame.payload
|
27
|
-
when Protocol::Connection::Start
|
28
|
-
send Protocol::Connection::StartOk.new(
|
29
|
-
{
|
30
|
-
:platform => 'Ruby/EventMachine',
|
31
|
-
:product => 'StormMQ AMQP',
|
32
|
-
:information => 'http://github.com/tonybyrne/StormMQ-Ruby-Client/',
|
33
|
-
:version => VERSION
|
34
|
-
},
|
35
|
-
'AMQPLAIN',
|
36
|
-
{
|
37
|
-
:LOGIN => @settings[:user],
|
38
|
-
:PASSWORD => @settings[:password]
|
39
|
-
},
|
40
|
-
'en_US'
|
41
|
-
)
|
42
|
-
|
43
|
-
when Protocol::Connection::Tune
|
44
|
-
send Protocol::Connection::TuneOk.new(
|
45
|
-
:channel_max => 0,
|
46
|
-
:frame_max => 131072,
|
47
|
-
:heartbeat => 0
|
48
|
-
)
|
10
|
+
require 'bunny'
|
11
|
+
require 'stormmq/version'
|
49
12
|
|
50
|
-
|
51
|
-
:virtual_host => @settings[:vhost],
|
52
|
-
:capabilities => '',
|
53
|
-
:insist => @settings[:insist]
|
54
|
-
)
|
55
|
-
|
56
|
-
when Protocol::Connection::OpenOk
|
57
|
-
succeed(self)
|
13
|
+
module StormMQ
|
58
14
|
|
59
|
-
|
60
|
-
STDERR.puts "#{method.reply_text} in #{Protocol.classes[method.class_id].methods[method.method_id]}"
|
15
|
+
module AMQPClient
|
61
16
|
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
17
|
+
def self.instance(options={})
|
18
|
+
Bunny.new(self.add_stormmq_options(options))
|
66
19
|
end
|
67
|
-
end
|
68
20
|
|
69
|
-
|
21
|
+
def self.run(options={}, &block)
|
22
|
+
Bunny.run(self.add_stormmq_options(options), &block)
|
23
|
+
end
|
70
24
|
|
71
|
-
def self.
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
:ssl => true
|
79
|
-
}.merge(options)
|
80
|
-
)
|
25
|
+
def self.add_stormmq_options(options={})
|
26
|
+
{
|
27
|
+
:vhost => self.vhost_from_options(options),
|
28
|
+
:host => 'amqp.stormmq.com',
|
29
|
+
:port => 443,
|
30
|
+
:ssl => true
|
31
|
+
}.merge(options)
|
81
32
|
end
|
82
33
|
|
83
34
|
def self.vhost_from_options(options)
|
data/lib/stormmq/rest.rb
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
require 'stormmq/url'
|
10
10
|
require 'stormmq/errors'
|
11
11
|
require 'stormmq/secret_keys'
|
12
|
+
require 'stormmq/utils'
|
12
13
|
require 'json'
|
13
14
|
require 'rest_client'
|
14
15
|
|
@@ -27,7 +28,7 @@ module StormMQ
|
|
27
28
|
|
28
29
|
class Rest
|
29
30
|
|
30
|
-
RestClient.proxy = ENV['http_proxy'] unless ENV['http_proxy'].
|
31
|
+
RestClient.proxy = ENV['http_proxy'] unless ENV['http_proxy'].blank?
|
31
32
|
|
32
33
|
def initialize(options={})
|
33
34
|
unless @user = options.delete(:user)
|
data/lib/stormmq/utils.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stormmq-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tony Byrne
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain:
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-08 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- lib/stormmq/secret_keys.rb
|
194
194
|
- lib/stormmq/url.rb
|
195
195
|
- lib/stormmq/utils.rb
|
196
|
+
- lib/stormmq/version.rb
|
196
197
|
- bin/stormmq-amqp-echo-test
|
197
198
|
- bin/stormmq-create-system
|
198
199
|
- bin/stormmq-delete-system
|
@@ -212,6 +213,7 @@ files:
|
|
212
213
|
- spec/stormmq/secret_keys_spec.rb
|
213
214
|
- spec/stormmq/url_spec.rb
|
214
215
|
- spec/stormmq/utils_spec.rb
|
216
|
+
- CHANGELOG
|
215
217
|
- LICENSE
|
216
218
|
- Rakefile
|
217
219
|
- README
|