amq-client 0.5.0
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/.gitignore +8 -0
- data/.gitmodules +9 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/.yardopts +1 -0
- data/CONTRIBUTORS +3 -0
- data/Gemfile +27 -0
- data/LICENSE +20 -0
- data/README.textile +61 -0
- data/amq-client.gemspec +34 -0
- data/bin/jenkins.sh +23 -0
- data/bin/set_test_suite_realms_up.sh +24 -0
- data/examples/coolio_adapter/basic_consume.rb +49 -0
- data/examples/coolio_adapter/basic_consume_with_acknowledgements.rb +43 -0
- data/examples/coolio_adapter/basic_consume_with_rejections.rb +43 -0
- data/examples/coolio_adapter/basic_publish.rb +35 -0
- data/examples/coolio_adapter/channel_close.rb +24 -0
- data/examples/coolio_adapter/example_helper.rb +39 -0
- data/examples/coolio_adapter/exchange_declare.rb +28 -0
- data/examples/coolio_adapter/kitchen_sink1.rb +48 -0
- data/examples/coolio_adapter/queue_bind.rb +32 -0
- data/examples/coolio_adapter/queue_purge.rb +32 -0
- data/examples/coolio_adapter/queue_unbind.rb +37 -0
- data/examples/eventmachine_adapter/authentication/plain_password_with_custom_role_credentials.rb +36 -0
- data/examples/eventmachine_adapter/authentication/plain_password_with_default_role_credentials.rb +27 -0
- data/examples/eventmachine_adapter/authentication/plain_password_with_incorrect_credentials.rb +18 -0
- data/examples/eventmachine_adapter/basic_cancel.rb +49 -0
- data/examples/eventmachine_adapter/basic_consume.rb +51 -0
- data/examples/eventmachine_adapter/basic_consume_with_acknowledgements.rb +45 -0
- data/examples/eventmachine_adapter/basic_consume_with_rejections.rb +45 -0
- data/examples/eventmachine_adapter/basic_get.rb +57 -0
- data/examples/eventmachine_adapter/basic_get_with_empty_queue.rb +53 -0
- data/examples/eventmachine_adapter/basic_publish.rb +38 -0
- data/examples/eventmachine_adapter/basic_qos.rb +29 -0
- data/examples/eventmachine_adapter/basic_recover.rb +29 -0
- data/examples/eventmachine_adapter/basic_return.rb +34 -0
- data/examples/eventmachine_adapter/channel_close.rb +24 -0
- data/examples/eventmachine_adapter/channel_flow.rb +36 -0
- data/examples/eventmachine_adapter/channel_level_exception_handling.rb +44 -0
- data/examples/eventmachine_adapter/example_helper.rb +39 -0
- data/examples/eventmachine_adapter/exchange_declare.rb +54 -0
- data/examples/eventmachine_adapter/extensions/rabbitmq/handling_confirm_select_ok.rb +31 -0
- data/examples/eventmachine_adapter/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb +56 -0
- data/examples/eventmachine_adapter/extensions/rabbitmq/publisher_confirmations_with_unroutable_message.rb +46 -0
- data/examples/eventmachine_adapter/kitchen_sink1.rb +50 -0
- data/examples/eventmachine_adapter/queue_bind.rb +32 -0
- data/examples/eventmachine_adapter/queue_declare.rb +34 -0
- data/examples/eventmachine_adapter/queue_purge.rb +32 -0
- data/examples/eventmachine_adapter/queue_unbind.rb +37 -0
- data/examples/eventmachine_adapter/tx_commit.rb +29 -0
- data/examples/eventmachine_adapter/tx_rollback.rb +29 -0
- data/examples/eventmachine_adapter/tx_select.rb +27 -0
- data/examples/socket_adapter/basics.rb +19 -0
- data/examples/socket_adapter/connection.rb +53 -0
- data/examples/socket_adapter/multiple_connections.rb +17 -0
- data/irb.rb +66 -0
- data/lib/amq/client.rb +15 -0
- data/lib/amq/client/adapter.rb +356 -0
- data/lib/amq/client/adapters/coolio.rb +221 -0
- data/lib/amq/client/adapters/event_machine.rb +228 -0
- data/lib/amq/client/adapters/socket.rb +89 -0
- data/lib/amq/client/channel.rb +338 -0
- data/lib/amq/client/connection.rb +246 -0
- data/lib/amq/client/entity.rb +117 -0
- data/lib/amq/client/exceptions.rb +86 -0
- data/lib/amq/client/exchange.rb +163 -0
- data/lib/amq/client/extensions/rabbitmq.rb +5 -0
- data/lib/amq/client/extensions/rabbitmq/basic.rb +36 -0
- data/lib/amq/client/extensions/rabbitmq/confirm.rb +254 -0
- data/lib/amq/client/framing/io/frame.rb +32 -0
- data/lib/amq/client/framing/string/frame.rb +62 -0
- data/lib/amq/client/logging.rb +56 -0
- data/lib/amq/client/mixins/anonymous_entity.rb +21 -0
- data/lib/amq/client/mixins/status.rb +62 -0
- data/lib/amq/client/protocol/get_response.rb +55 -0
- data/lib/amq/client/queue.rb +450 -0
- data/lib/amq/client/settings.rb +83 -0
- data/lib/amq/client/version.rb +5 -0
- data/spec/benchmarks/adapters.rb +77 -0
- data/spec/client/framing/io_frame_spec.rb +57 -0
- data/spec/client/framing/string_frame_spec.rb +57 -0
- data/spec/client/protocol/get_response_spec.rb +79 -0
- data/spec/integration/coolio/basic_ack_spec.rb +41 -0
- data/spec/integration/coolio/basic_get_spec.rb +73 -0
- data/spec/integration/coolio/basic_return_spec.rb +33 -0
- data/spec/integration/coolio/channel_close_spec.rb +26 -0
- data/spec/integration/coolio/channel_flow_spec.rb +46 -0
- data/spec/integration/coolio/spec_helper.rb +31 -0
- data/spec/integration/coolio/tx_commit_spec.rb +40 -0
- data/spec/integration/coolio/tx_rollback_spec.rb +44 -0
- data/spec/integration/eventmachine/basic_ack_spec.rb +40 -0
- data/spec/integration/eventmachine/basic_get_spec.rb +73 -0
- data/spec/integration/eventmachine/basic_return_spec.rb +35 -0
- data/spec/integration/eventmachine/channel_close_spec.rb +26 -0
- data/spec/integration/eventmachine/channel_flow_spec.rb +32 -0
- data/spec/integration/eventmachine/spec_helper.rb +22 -0
- data/spec/integration/eventmachine/tx_commit_spec.rb +47 -0
- data/spec/integration/eventmachine/tx_rollback_spec.rb +35 -0
- data/spec/regression/bad_frame_slicing_in_adapters_spec.rb +59 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/unit/client/adapter_spec.rb +49 -0
- data/spec/unit/client/entity_spec.rb +49 -0
- data/spec/unit/client/logging_spec.rb +60 -0
- data/spec/unit/client/mixins/status_spec.rb +72 -0
- data/spec/unit/client/settings_spec.rb +27 -0
- data/spec/unit/client_spec.rb +11 -0
- data/tasks.rb +11 -0
- metadata +202 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "example_helper")
|
|
6
|
+
|
|
7
|
+
amq_client_example "Declare a new fanout exchange" do |client|
|
|
8
|
+
puts "AMQP connection is open: #{client.connection.server_properties.inspect}"
|
|
9
|
+
|
|
10
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
11
|
+
channel.open do
|
|
12
|
+
puts "Channel #{channel.id} is now open!"
|
|
13
|
+
|
|
14
|
+
exchange_name = "amqclient.adapters.em.exchange"
|
|
15
|
+
|
|
16
|
+
10.times do
|
|
17
|
+
exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout)
|
|
18
|
+
exchange.declare
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
exchange2 = AMQ::Client::Exchange.new(client, channel, exchange_name + "-2", :fanout)
|
|
22
|
+
exchange2.declare
|
|
23
|
+
|
|
24
|
+
AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout).declare do |exchange, declare_ok|
|
|
25
|
+
puts "Channel is aware of the following exchanges: #{channel.exchanges.map { |e| e.name }.join(', ')}"
|
|
26
|
+
|
|
27
|
+
exchange.delete do
|
|
28
|
+
puts "Exchange #{exchange.name} was successfully deleted"
|
|
29
|
+
exchange2.delete do
|
|
30
|
+
puts "Exchange #{exchange2.name} was successfully deleted"
|
|
31
|
+
|
|
32
|
+
client.disconnect do
|
|
33
|
+
puts
|
|
34
|
+
puts "AMQP connection is now properly closed"
|
|
35
|
+
EM.stop
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
show_stopper = Proc.new {
|
|
42
|
+
client.disconnect do
|
|
43
|
+
puts
|
|
44
|
+
puts "AMQP connection is now properly closed"
|
|
45
|
+
EM.stop
|
|
46
|
+
end
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Signal.trap "INT", show_stopper
|
|
50
|
+
Signal.trap "TERM", show_stopper
|
|
51
|
+
|
|
52
|
+
EM.add_timer(2, show_stopper)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "..", "..", "example_helper")
|
|
6
|
+
|
|
7
|
+
require "amq/client/extensions/rabbitmq/confirm"
|
|
8
|
+
|
|
9
|
+
amq_client_example "confirm.select (a RabbitMQ extension)" do |client|
|
|
10
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
11
|
+
channel.open do
|
|
12
|
+
puts "Channel #{channel.id} is now open"
|
|
13
|
+
|
|
14
|
+
channel.confirmations do |select_ok|
|
|
15
|
+
puts "Broker replied with confirm.select_ok"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
show_stopper = Proc.new {
|
|
19
|
+
client.disconnect do
|
|
20
|
+
puts
|
|
21
|
+
puts "AMQP connection is now properly closed"
|
|
22
|
+
EM.stop
|
|
23
|
+
end
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Signal.trap "INT", show_stopper
|
|
27
|
+
Signal.trap "TERM", show_stopper
|
|
28
|
+
|
|
29
|
+
EM.add_timer(1, show_stopper)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "..", "..", "example_helper")
|
|
6
|
+
|
|
7
|
+
require "amq/client/extensions/rabbitmq/confirm"
|
|
8
|
+
|
|
9
|
+
amq_client_example "Publisher confirmations using RabbitMQ extension: routable message scenario" do |client|
|
|
10
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
11
|
+
channel.open do
|
|
12
|
+
puts "Channel #{channel.id} is now open"
|
|
13
|
+
|
|
14
|
+
channel.confirmations
|
|
15
|
+
channel.on_error do
|
|
16
|
+
puts "Oops, there is a channel-levle exceptions!"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
channel.confirm do |basic_ack|
|
|
21
|
+
puts "Received basic_ack: multiple = #{basic_ack.multiple}, delivery_tag = #{basic_ack.delivery_tag}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
x = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout)
|
|
25
|
+
|
|
26
|
+
q = AMQ::Client::Queue.new(client, channel, AMQ::Protocol::EMPTY_STRING)
|
|
27
|
+
q.declare(false, false, true, true) do |_|
|
|
28
|
+
puts "Defined a new server-named queue: #{q.name}"
|
|
29
|
+
|
|
30
|
+
q.bind("amq.fanout").consume(false, true, true) { |consume_ok|
|
|
31
|
+
puts "Received basic.consume-ok"
|
|
32
|
+
}.on_delivery do |method, header, payload|
|
|
33
|
+
puts "Received #{payload}"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
EM.add_timer(0.5) do
|
|
38
|
+
10.times { |i| x.publish("Message ##{i}", AMQ::Protocol::EMPTY_STRING, { :delivery_mode => 2 }, true) }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
show_stopper = Proc.new {
|
|
44
|
+
client.disconnect do
|
|
45
|
+
puts
|
|
46
|
+
puts "AMQP connection is now properly closed"
|
|
47
|
+
EM.stop
|
|
48
|
+
end
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Signal.trap "INT", show_stopper
|
|
52
|
+
Signal.trap "TERM", show_stopper
|
|
53
|
+
|
|
54
|
+
EM.add_timer(3, show_stopper)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "..", "..", "example_helper")
|
|
6
|
+
|
|
7
|
+
require "amq/client/extensions/rabbitmq/confirm"
|
|
8
|
+
|
|
9
|
+
amq_client_example "Publisher confirmations using RabbitMQ extension: unroutable message scenario" do |client|
|
|
10
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
11
|
+
channel.open do
|
|
12
|
+
puts "Channel #{channel.id} is now open"
|
|
13
|
+
|
|
14
|
+
channel.confirmations
|
|
15
|
+
channel.on_error do
|
|
16
|
+
puts "Oops, there is a channel-levle exceptions!"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
channel.confirm do |basic_ack|
|
|
21
|
+
puts "Received basic_ack: multiple = #{basic_ack.multiple}, delivery_tag = #{basic_ack.delivery_tag}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
x = AMQ::Client::Exchange.new(client, channel, AMQ::Protocol::EMPTY_STRING, :direct)
|
|
25
|
+
x.on_return { |basic_return|
|
|
26
|
+
puts "Received basic.return: reply_text = #{basic_return.reply_text}, reply_code = #{basic_return.reply_code}"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
10.times { x.publish("A message", AMQ::Protocol::EMPTY_STRING, {}, true) }
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
show_stopper = Proc.new {
|
|
34
|
+
client.disconnect do
|
|
35
|
+
puts
|
|
36
|
+
puts "AMQP connection is now properly closed"
|
|
37
|
+
EM.stop
|
|
38
|
+
end
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Signal.trap "INT", show_stopper
|
|
42
|
+
Signal.trap "TERM", show_stopper
|
|
43
|
+
|
|
44
|
+
EM.add_timer(3, show_stopper)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "example_helper")
|
|
6
|
+
|
|
7
|
+
amq_client_example "An example that combines several AMQ operations" do |client|
|
|
8
|
+
puts "AMQP connection is open: #{client.connection.server_properties.inspect}"
|
|
9
|
+
|
|
10
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
11
|
+
channel.open do
|
|
12
|
+
puts "Channel #{channel.id} is now open!"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
queue = AMQ::Client::Queue.new(client, channel, "amqclient.queue2")
|
|
16
|
+
queue.declare(false, false, false, true) do
|
|
17
|
+
puts "Queue #{queue.name.inspect} is now declared!"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
exchange = AMQ::Client::Exchange.new(client, channel, "amqclient.adapters.em.exchange1", :fanout)
|
|
21
|
+
exchange.declare { puts "Exchange #{exchange.name.inspect} is now declared!" }
|
|
22
|
+
|
|
23
|
+
queue.consume do |msg|
|
|
24
|
+
puts msg
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
show_stopper = Proc.new {
|
|
29
|
+
puts
|
|
30
|
+
puts "Deleting queue #{queue.name}"
|
|
31
|
+
queue.delete do |message_count|
|
|
32
|
+
puts
|
|
33
|
+
puts "Deleted #{queue.name}. It had #{message_count} messages in it."
|
|
34
|
+
puts
|
|
35
|
+
puts "Deleting exchange #{exchange.name}"
|
|
36
|
+
exchange.delete do
|
|
37
|
+
client.disconnect do
|
|
38
|
+
puts
|
|
39
|
+
puts "AMQP connection is now properly closed"
|
|
40
|
+
EM.stop
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
Signal.trap "INT", show_stopper
|
|
47
|
+
Signal.trap "TERM", show_stopper
|
|
48
|
+
|
|
49
|
+
EM.add_timer(1, show_stopper)
|
|
50
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "example_helper")
|
|
6
|
+
|
|
7
|
+
amq_client_example "Bind a new queue to amq.fanout" do |client|
|
|
8
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
9
|
+
channel.open do
|
|
10
|
+
puts "Channel #{channel.id} is now open!"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
AMQ::Client::Queue.new(client, channel, "amqclient.queue2").declare do |queue, declare_ok|
|
|
14
|
+
puts queue.class.name
|
|
15
|
+
puts "Queue #{queue.name.inspect} is now declared!"
|
|
16
|
+
|
|
17
|
+
queue.bind("amq.fanout") do
|
|
18
|
+
puts "Queue #{queue.name} is now bound to amq.fanout"
|
|
19
|
+
puts
|
|
20
|
+
puts "Deleting queue #{queue.name}"
|
|
21
|
+
queue.delete do |message_count|
|
|
22
|
+
puts "Deleted."
|
|
23
|
+
puts
|
|
24
|
+
client.disconnect do
|
|
25
|
+
puts
|
|
26
|
+
puts "AMQP connection is now properly closed"
|
|
27
|
+
EM.stop
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "example_helper")
|
|
6
|
+
|
|
7
|
+
amq_client_example "Purge a queue and announce how many messages it had" do |client|
|
|
8
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
9
|
+
channel.open do
|
|
10
|
+
puts "Channel #{channel.id} is now open!"
|
|
11
|
+
|
|
12
|
+
4.times do
|
|
13
|
+
q = AMQ::Client::Queue.new(client, channel, AMQ::Protocol::EMPTY_STRING)
|
|
14
|
+
q.declare(false, false, false, true)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
begin
|
|
18
|
+
q = AMQ::Client::Queue.new(client, channel, AMQ::Protocol::EMPTY_STRING)
|
|
19
|
+
q.declare(false, false, false, true, true)
|
|
20
|
+
rescue ArgumentError => e
|
|
21
|
+
puts "Non-sensical declaration of a server-named queue with nowait did not slip through, great"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
queue = AMQ::Client::Queue.new(client, channel, AMQ::Protocol::EMPTY_STRING)
|
|
26
|
+
queue.declare(false, false, false, true) do
|
|
27
|
+
puts "Queue #{queue.name.inspect} is now declared!"
|
|
28
|
+
|
|
29
|
+
puts "Channel is aware of the following queues: #{channel.queues.map { |q| q.name }.join(', ')}"
|
|
30
|
+
|
|
31
|
+
client.disconnect { EM.stop }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "example_helper")
|
|
6
|
+
|
|
7
|
+
amq_client_example "Purge a queue and announce how many messages it had" do |client|
|
|
8
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
9
|
+
channel.open do
|
|
10
|
+
puts "Channel #{channel.id} is now open!"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
queue = AMQ::Client::Queue.new(client, channel, "amqclient.queue2")
|
|
14
|
+
queue.declare(false, false, false, true) do
|
|
15
|
+
puts "Queue #{queue.name.inspect} is now declared!"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
queue.purge do |message_count|
|
|
19
|
+
puts "Queue #{queue.name} is now purged. It had #{message_count} messages."
|
|
20
|
+
puts
|
|
21
|
+
puts "Deleting queue #{queue.name}"
|
|
22
|
+
queue.delete do |message_count|
|
|
23
|
+
puts "Deleted."
|
|
24
|
+
puts
|
|
25
|
+
client.disconnect do
|
|
26
|
+
puts
|
|
27
|
+
puts "AMQP connection is now properly closed"
|
|
28
|
+
EM.stop
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "example_helper")
|
|
6
|
+
|
|
7
|
+
amq_client_example "Bind and then unbind a queue to amq.fanout" do |client|
|
|
8
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
9
|
+
channel.open do
|
|
10
|
+
puts "Channel #{channel.id} is now open!"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
queue = AMQ::Client::Queue.new(client, channel, "amqclient.queue2")
|
|
14
|
+
queue.declare do
|
|
15
|
+
puts "Queue #{queue.name.inspect} is now declared!"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
queue.bind("amq.fanout") do
|
|
19
|
+
puts "Queue #{queue.name} is now bound to amq.fanout"
|
|
20
|
+
|
|
21
|
+
queue.unbind("amq.fanout") do
|
|
22
|
+
puts "Queue #{queue.name} is now unbound from amq.fanout"
|
|
23
|
+
|
|
24
|
+
puts
|
|
25
|
+
puts "Deleting queue #{queue.name}"
|
|
26
|
+
queue.delete do |message_count|
|
|
27
|
+
puts "Deleted."
|
|
28
|
+
puts
|
|
29
|
+
client.disconnect do
|
|
30
|
+
puts
|
|
31
|
+
puts "AMQP connection is now properly closed"
|
|
32
|
+
EM.stop
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "example_helper")
|
|
6
|
+
|
|
7
|
+
amq_client_example "Commit acknowledgement transaction using tx.commit" do |client|
|
|
8
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
9
|
+
channel.open do
|
|
10
|
+
channel.tx_select do |_|
|
|
11
|
+
channel.tx_commit do |_|
|
|
12
|
+
puts "Transaction on channel #{channel.id} is now committed"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
show_stopper = Proc.new {
|
|
17
|
+
client.disconnect do
|
|
18
|
+
puts
|
|
19
|
+
puts "AMQP connection is now properly closed"
|
|
20
|
+
EM.stop
|
|
21
|
+
end
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Signal.trap "INT", show_stopper
|
|
25
|
+
Signal.trap "TERM", show_stopper
|
|
26
|
+
|
|
27
|
+
EM.add_timer(1, show_stopper)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
__dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
require File.join(__dir, "example_helper")
|
|
6
|
+
|
|
7
|
+
amq_client_example "Rollback acknowledgement transaction using tx.rollback" do |client|
|
|
8
|
+
channel = AMQ::Client::Channel.new(client, 1)
|
|
9
|
+
channel.open do
|
|
10
|
+
channel.tx_select do |_|
|
|
11
|
+
channel.tx_rollback do |_|
|
|
12
|
+
puts "Transaction on channel #{channel.id} is now rolled back"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
show_stopper = Proc.new {
|
|
17
|
+
client.disconnect do
|
|
18
|
+
puts
|
|
19
|
+
puts "AMQP connection is now properly closed"
|
|
20
|
+
EM.stop
|
|
21
|
+
end
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Signal.trap "INT", show_stopper
|
|
25
|
+
Signal.trap "TERM", show_stopper
|
|
26
|
+
|
|
27
|
+
EM.add_timer(1, show_stopper)
|
|
28
|
+
end
|
|
29
|
+
end
|