amq-client 0.7.0.alpha21 → 0.7.0.alpha22

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ __dir = File.join(File.dirname(File.expand_path(__FILE__)), "..")
5
+ require File.join(__dir, "example_helper")
6
+
7
+ begin
8
+ EventMachine.run do
9
+
10
+ show_stopper = Proc.new {
11
+ EM.stop
12
+ }
13
+
14
+ Signal.trap "INT", show_stopper
15
+ Signal.trap "TERM", show_stopper
16
+
17
+ EventMachine.add_timer(4, show_stopper)
18
+
19
+ AMQ::Client::EventMachineClient.connect(:port => 9689,
20
+ :vhost => "/a/b/c/#{rand}/d/#{Time.now.to_i}",
21
+ :user => "amq_client_gem",
22
+ :password => "amq_client_gem_password",
23
+ :timeout => 0.3) do |client|
24
+ raise "Connected, authenticated. This is not what this example is supposed to do!"
25
+ end
26
+ end
27
+ rescue AMQ::Client::TCPConnectionFailed => e
28
+ puts "TCP connection has failed, as expected. Shutting down…"
29
+ EventMachine.stop if EventMachine.reactor_running?
30
+ end
@@ -10,8 +10,9 @@ amq_client_example "basic.return example" do |client|
10
10
  queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true)
11
11
 
12
12
  exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout)
13
- exchange.on_return do |method|
13
+ exchange.on_return do |method, header, body|
14
14
  puts "Handling a returned message: exchange = #{method.exchange}, reply_code = #{method.reply_code}, reply_text = #{method.reply_text}"
15
+ puts "Body of the returned message: #{body}"
15
16
  end
16
17
 
17
18
  10.times do |i|
@@ -154,21 +154,18 @@ module AMQ
154
154
  define_callback :tcp_connection_failure, &block
155
155
  end
156
156
 
157
- # Sets a callback for successful connection (after we receive tune-ok)
158
- #
159
- # @api public
160
- def on_open(&block)
161
- define_callback :open, &block
162
- end # on_open(&block)
163
-
164
157
 
165
158
  # Called by AMQ::Client::Connection after we receive connection.open-ok.
166
159
  #
167
160
  # @api private
168
161
  def connection_successful
162
+ @authenticating = false
163
+ opened!
164
+
169
165
  exec_callback_yielding_self(:connect)
170
166
  end
171
167
 
168
+
172
169
  # Called by AMQ::Client::Connection after we receive connection.close-ok.
173
170
  #
174
171
  # @api private
@@ -178,14 +175,6 @@ module AMQ
178
175
  closed!
179
176
  end
180
177
 
181
- # Called by AMQ::Client::Connection after we receive connection.tune.
182
- #
183
- # @api private
184
- def open_successful
185
- @authenticating = false
186
- opened!
187
- exec_callback_yielding_self(:open)
188
- end # open_successful
189
178
 
190
179
  # Called by Socket if it could not connect.
191
180
  #
@@ -59,26 +59,16 @@ module AMQ
59
59
  end
60
60
 
61
61
 
62
- # Defines a callback that will be executed when AMQP connection is considered open,
63
- # after client and broker has agreed on max channel identifier and maximum allowed frame
64
- # size. You can define more than one callback.
62
+ # Defines a callback that will be executed when AMQP connection is considered open:
63
+ # client and broker has agreed on max channel identifier and maximum allowed frame
64
+ # size and authentication succeeds. You can define more than one callback.
65
65
  #
66
- # @see #on_open
66
+ # @see on_possible_authentication_failure
67
67
  # @api public
68
68
  def on_connection(&block)
69
69
  @connection_deferrable.callback(&block)
70
70
  end # on_connection(&block)
71
71
 
72
- # Defines a callback that will be executed when AMQP connection is considered open,
73
- # before client and broker has agreed on max channel identifier and maximum allowed frame
74
- # size. You can define more than one callback.
75
- #
76
- # @see #on_connection
77
- # @api public
78
- def on_open(&block)
79
- @connection_opened_deferrable.callback(&block)
80
- end # on_open(&block)
81
-
82
72
  # Defines a callback that will be run when broker confirms connection termination
83
73
  # (client receives connection.close-ok). You can define more than one callback.
84
74
  #
@@ -283,18 +273,11 @@ module AMQ
283
273
  # Called by AMQ::Client::Connection after we receive connection.open-ok.
284
274
  # @api public
285
275
  def connection_successful
286
- @connection_deferrable.succeed
287
- end # connection_successful
288
-
289
-
290
- # Called by AMQ::Client::Connection after we receive connection.tune.
291
- # @api public
292
- def open_successful
293
276
  @authenticating = false
294
- @connection_opened_deferrable.succeed
295
-
296
277
  opened!
297
- end # open_successful
278
+
279
+ @connection_deferrable.succeed
280
+ end # connection_successful
298
281
 
299
282
 
300
283
  # Called by AMQ::Client::Connection after we receive connection.close-ok.
@@ -344,9 +327,6 @@ module AMQ
344
327
  @chunk_buffer = ""
345
328
  @connection_deferrable = Deferrable.new
346
329
  @disconnection_deferrable = Deferrable.new
347
- # succeeds when connection is open, that is, vhost is selected
348
- # and client is given green light to proceed.
349
- @connection_opened_deferrable = Deferrable.new
350
330
 
351
331
  # used to track down whether authentication succeeded. AMQP 0.9.1 dictates
352
332
  # that on authentication failure broker must close TCP connection without sending
@@ -234,7 +234,6 @@ module AMQ
234
234
  client.connection.handle_tune(frame.decode_payload)
235
235
 
236
236
  client.connection.open(client.settings[:vhost] || "/")
237
- client.open_successful
238
237
  end
239
238
 
240
239
  self.handle(Protocol::Connection::OpenOk) do |client, frame|
@@ -150,12 +150,15 @@ module AMQ
150
150
  end # handle
151
151
 
152
152
 
153
- self.handle(Protocol::Basic::Return) do |client, frame|
153
+ self.handle(Protocol::Basic::Return) do |client, frame, content_frames|
154
154
  channel = client.connection.channels[frame.channel]
155
155
  method = frame.decode_payload
156
156
  exchange = channel.find_exchange(method.exchange)
157
157
 
158
- exchange.exec_callback(:return, method)
158
+ header = content_frames.shift
159
+ body = content_frames.map { |frame| frame.payload }.join
160
+
161
+ exchange.exec_callback(:return, method, header, body)
159
162
  end
160
163
 
161
164
  end # Exchange
@@ -1,5 +1,5 @@
1
1
  module AMQ
2
2
  module Client
3
- VERSION = "0.7.0.alpha21"
3
+ VERSION = "0.7.0.alpha22"
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@ describe "AMQ::Client::CoolioClient", "Basic.Return", :nojruby => true do
19
19
  # hence, no auto-delete
20
20
  delayed(0.4) { queue.delete }
21
21
 
22
- exchange = AMQ::Client::Exchange.new(client, channel, "direct-exchange", :direct).declare.on_return do |method|
22
+ exchange = AMQ::Client::Exchange.new(client, channel, "direct-exchange", :direct).declare.on_return do |method, header, body|
23
23
  @returned_messages << method.reply_text
24
24
  end
25
25
 
@@ -18,7 +18,7 @@ describe AMQ::Client::EventMachineClient, "Basic.Return" do
18
18
  # hence, no auto-delete
19
19
  delayed(0.4) { queue.delete }
20
20
 
21
- exchange = AMQ::Client::Exchange.new(client, channel, "direct-exchange", :direct).declare.on_return do |method|
21
+ exchange = AMQ::Client::Exchange.new(client, channel, "direct-exchange", :direct).declare.on_return do |method, header, body|
22
22
  @returned_messages << method.reply_text
23
23
  end
24
24
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amq-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: -3702664442
4
+ hash: -3702664448
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
9
  - 0
10
10
  - alpha
11
- - 21
12
- version: 0.7.0.alpha21
11
+ - 22
12
+ version: 0.7.0.alpha22
13
13
  platform: ruby
14
14
  authors:
15
15
  - Jakub Stastny
@@ -20,7 +20,7 @@ autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
22
 
23
- date: 2011-05-10 00:00:00 Z
23
+ date: 2011-05-14 00:00:00 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: eventmachine
@@ -80,7 +80,6 @@ files:
80
80
  - LICENSE
81
81
  - README.textile
82
82
  - amq-client.gemspec
83
- - bin/jenkins.sh
84
83
  - bin/set_test_suite_realms_up.sh
85
84
  - examples/coolio_adapter/basic_consume.rb
86
85
  - examples/coolio_adapter/basic_consume_with_acknowledgements.rb
@@ -93,6 +92,7 @@ files:
93
92
  - examples/coolio_adapter/queue_bind.rb
94
93
  - examples/coolio_adapter/queue_purge.rb
95
94
  - examples/coolio_adapter/queue_unbind.rb
95
+ - examples/eventmachine_adapter/authentication/connection_open_failure_due_to_invalid_vhost.rb
96
96
  - examples/eventmachine_adapter/authentication/plain_password_with_custom_role_credentials.rb
97
97
  - examples/eventmachine_adapter/authentication/plain_password_with_default_role_credentials.rb
98
98
  - examples/eventmachine_adapter/authentication/plain_password_with_incorrect_credentials_handled_with_a_callback.rb
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  requirements: []
254
254
 
255
255
  rubyforge_project: amq-client
256
- rubygems_version: 1.8.1
256
+ rubygems_version: 1.8.2
257
257
  signing_key:
258
258
  specification_version: 3
259
259
  summary: amq-client is a fully-featured, low-level AMQP 0.9.1 client
@@ -1,23 +0,0 @@
1
- #!/bin/bash
2
-
3
- echo -e "\n\n==== Setup ===="
4
- source /etc/profile
5
- git fetch && git reset origin/master --hard
6
-
7
- echo -e "\n\n==== Ruby 1.9.2 Head ===="
8
- rvm use 1.9.2-head@ruby-amqp
9
- gem install bundler --no-ri --no-rdoc
10
- bundle install --path vendor/bundle/1.9.2 --without development; echo
11
- bundle update amq-protocol evented-spec; echo
12
- bundle exec rspec spec
13
- return_status=$?
14
-
15
- echo -e "\n\n==== Ruby 1.8.7 ===="
16
- rvm use 1.8.7@ruby-amqp
17
- gem install bundler --no-ri --no-rdoc
18
- bundle install --path vendor/bundle/1.8.7 --without development; echo
19
- bundle update; echo
20
- bundle exec rspec spec
21
- return_status=$(expr $return_status + $?)
22
-
23
- test $return_status -eq 0