stormmq-client 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
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.
@@ -65,46 +65,45 @@ class StormMQ::Application::AMQPEchoTest < StormMQ::Application
65
65
 
66
66
  def main
67
67
 
68
- EM.run do
69
-
70
- puts "creating connection"
71
- connection = StormMQ::AMQPClient.connect(
72
- :user => opt.amqpUser,
73
- :password => opt.amqpPassword,
74
- :company => opt.company,
75
- :system => opt.system,
76
- :environment => opt.environment,
77
- :host => opt.host,
78
- :port => opt.port,
79
- :logging => opt['--debug']
80
- )
81
-
82
- puts "opening a channel on the A MQP connection"
83
- channel = MQ.new(connection)
84
-
85
- puts "declaring a queue on the channel"
86
- queue = MQ::Queue.new(channel, 'test queue')
87
-
88
- puts "creating a test exchange"
89
- exchange = MQ::Exchange.new(channel, :direct, 'test exchange')
90
-
91
- puts "binding the queue the the exchange"
92
- queue.bind(exchange)
93
-
94
- puts "publishing test message to the exchange"
95
- exchange.publish('hello world')
96
-
97
- puts "subsribing to the queue"
98
- queue.subscribe do |headers, msg|
99
- puts "recevied message from the queue:"
100
- pp headers
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
- module StormMQ
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
- send Protocol::Connection::Open.new(
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
- when Protocol::Connection::Close
60
- STDERR.puts "#{method.reply_text} in #{Protocol.classes[method.class_id].methods[method.method_id]}"
15
+ module AMQPClient
61
16
 
62
- when Protocol::Connection::CloseOk
63
- @on_disconnect.call if @on_disconnect
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
- module AMQPClient
21
+ def self.run(options={}, &block)
22
+ Bunny.run(self.add_stormmq_options(options), &block)
23
+ end
70
24
 
71
- def self.connect(options={})
72
- AMQP.client = AMQPClientImplementation
73
- AMQP.connect(
74
- {
75
- :vhost => self.vhost_from_options(options),
76
- :host => 'amqp.stormmq.com',
77
- :port => 443,
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'].nil?
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
@@ -8,9 +8,6 @@
8
8
 
9
9
  module StormMQ
10
10
  module Utils
11
- # def self.stormmq_credentials_string(user, password)
12
- # "\0#{user}\0#{password}"
13
- # end
14
11
  end
15
12
  end
16
13
 
@@ -0,0 +1,3 @@
1
+ module StormMQ
2
+ VERSION = '0.0.5'
3
+ end
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
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-07 00:00:00 +01:00
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