amqp 0.8.0.rc12 → 0.8.0.rc13
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/.yardopts +2 -1
- data/CONTRIBUTORS +29 -22
- data/Gemfile +2 -1
- data/README.md +241 -0
- data/amqp.gemspec +7 -5
- data/bin/set_test_suite_realms_up.sh +6 -6
- data/docs/08Migration.textile +3 -1
- data/docs/Bindings.textile +3 -1
- data/docs/Clustering.textile +4 -0
- data/docs/ConnectingToTheBroker.textile +108 -86
- data/docs/ConnectionEncryptionWithTLS.textile +3 -1
- data/docs/DocumentationGuidesIndex.textile +24 -2
- data/docs/Durability.textile +22 -1
- data/docs/ErrorHandling.textile +21 -1
- data/docs/Exchanges.textile +181 -9
- data/docs/GettingStarted.textile +65 -167
- data/docs/Queues.textile +400 -355
- data/docs/RabbitMQVersions.textile +34 -3
- data/docs/Routing.textile +4 -1
- data/docs/RunningTests.textile +116 -0
- data/docs/Troubleshooting.textile +131 -0
- data/docs/VendorSpecificExtensions.textile +20 -0
- data/examples/channels/qos_aka_prefetch.rb +3 -3
- data/examples/channels/qos_aka_prefetch_without_callback.rb +2 -2
- data/examples/error_handling/channel_level_exception.rb +1 -1
- data/examples/error_handling/channel_level_exception_with_multiple_channels_involved.rb +1 -0
- data/examples/error_handling/connection_level_exception.rb +26 -0
- data/examples/error_handling/global_channel_level_exception_handler.rb +3 -3
- data/examples/exchanges/autodeletion_of_exchanges.rb +37 -0
- data/examples/extensions/rabbitmq/per_queue_message_ttl.rb +3 -3
- data/examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb +2 -2
- data/examples/guides/getting_started/{03_babblr.rb → 03_blabbr.rb} +0 -0
- data/examples/guides/queues/01a_declaring_a_server_named_queue_using_queue_constructor.rb +18 -0
- data/examples/guides/queues/01b_declaring_a_queue_using_queue_constructor.rb +18 -0
- data/examples/guides/queues/02a_declaring_a_durable_shared_queue.rb +18 -0
- data/examples/guides/queues/02b_declaring_a_durable_shared_queue.rb +18 -0
- data/examples/guides/queues/03a_declaring_a_temporary_exclusive_queue.rb +19 -0
- data/examples/guides/queues/03b_declaring_a_temporary_exclusive_queue.rb +18 -0
- data/examples/guides/queues/{05_binding_a_queue_using_exchange_instance.rb → 04_bind_a_queue_using_exchange_instance.rb} +2 -2
- data/examples/guides/queues/{06_biding_a_queue_using_exchange_name_string.rb → 05_bind_a_queue_using_exchange_name.rb} +2 -2
- data/examples/guides/queues/{07_subscribing_to_receive_messages.rb → 06_subscribe_to_receive_messages.rb} +1 -1
- data/examples/guides/queues/{08_poll_for_messages.rb → 07_fetch_a_message_from_the_queue.rb} +1 -1
- data/examples/guides/queues/{09_unsubscribing_a_consumer.rb → 08_unsubscribing_a_consumer.rb} +0 -0
- data/examples/guides/queues/{10_unbinding_from_exchange.rb → 09_unbinding_from_exchange.rb} +2 -2
- data/examples/guides/queues/{11_purge_a_queue.rb → 10_purge_a_queue.rb} +2 -2
- data/examples/guides/queues/{12_deleting_a_queue.rb → 11_deleting_a_queue.rb} +2 -2
- data/examples/hello_world.rb +1 -1
- data/examples/hello_world_with_an_empty_string.rb +33 -0
- data/examples/issues/amq_client_issue_7.rb +31 -0
- data/examples/issues/amq_protocol_issue_14.rb +46 -0
- data/examples/issues/issue_75.rb +23 -0
- data/examples/issues/issue_79.rb +35 -0
- data/examples/issues/issue_80.rb +40 -0
- data/examples/publishing/{publishing_and_immediately_stopping_event_loop.rb → publishing_a_one_off_message.rb} +9 -12
- data/examples/publishing/publishing_callback.rb +52 -0
- data/examples/publishing/returned_messages.rb +3 -3
- data/examples/queues/accessing_message_metadata.rb +60 -0
- data/examples/queues/queue_status.rb +0 -7
- data/examples/queues/rejecting_messages_without_requeueuing.rb +47 -0
- data/examples/queues/using_explicit_acknowledgements.rb +96 -0
- data/examples/routing/headers_routing.rb +54 -0
- data/lib/amqp/channel.rb +245 -40
- data/lib/amqp/client.rb +23 -11
- data/lib/amqp/exchange.rb +58 -41
- data/lib/amqp/queue.rb +66 -13
- data/lib/amqp/version.rb +1 -1
- data/spec/integration/authentication_spec.rb +5 -5
- data/spec/integration/basic_get_spec.rb +1 -1
- data/spec/integration/channel_close_spec.rb +10 -3
- data/spec/integration/queue_declaration_spec.rb +26 -5
- data/spec/integration/topic_subscription_spec.rb +1 -1
- data/spec/unit/amqp/client_spec.rb +7 -54
- data/tasks.rb +1 -8
- metadata +64 -23
- data/README.textile +0 -229
@@ -1,10 +1,23 @@
|
|
1
|
-
|
1
|
+
# @title Ruby AMQP gem: RabbitMQ versions compatibility
|
2
|
+
|
3
|
+
h1. Ruby amqp gem and RabbitMQ versions compatibility
|
4
|
+
|
5
|
+
h2. About this guide
|
6
|
+
|
7
|
+
This guide covers compatibility of the "Ruby amqp gem":http://github.com/ruby-amqp/amqp with various versions of "RabbitMQ":http://rabbitmq.com messaging broker.
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
h2. Covered versions
|
12
|
+
|
13
|
+
This guide covers "Ruby amqp gem":http://github.com/ruby-amqp/amqp v0.6.0 and later.
|
14
|
+
|
15
|
+
|
2
16
|
|
3
17
|
h2. Using recent versions on Debian and Ubuntu
|
4
18
|
|
5
19
|
Ubuntu (even 10.10) and Debian both "ship with old RabbitMQ version":http://packages.ubuntu.com/maverick/rabbitmq-server,
|
6
|
-
that only supports AMQP protocol 0.8. amqp gem 0.8.0 and later *will not work with RabbitMQ versions
|
7
|
-
before 2.0.0*.
|
20
|
+
that only supports AMQP protocol 0.8. Ruby amqp gem 0.8.0 and later *will not work with RabbitMQ versions before 2.0.0*.
|
8
21
|
|
9
22
|
We strongly recommend that you use "RabbitMQ apt repository":http://www.rabbitmq.com/debian.html#apt that has recent versions of RabbitMQ.
|
10
23
|
|
@@ -29,3 +42,21 @@ what was unclear? what wasn't covered? maybe you don't like guide style or gramm
|
|
29
42
|
key to making documentation better.
|
30
43
|
|
31
44
|
If mailing list communication is not an option for you for some reason, you can "contact guides author directly":mailto:michael@novemberain.com?subject=amqp%20gem%20documentation
|
45
|
+
|
46
|
+
|
47
|
+
<div id="disqus_thread"></div>
|
48
|
+
<script type="text/javascript">
|
49
|
+
/* * * CONFIGURATION VARIABLES * * */
|
50
|
+
var disqus_shortname = 'rubyamqpdocs'; // required: replace example with your forum shortname
|
51
|
+
|
52
|
+
var disqus_developer = 0; // set to 1 on local machine for testing comments
|
53
|
+
var disqus_identifier = 'amqp_rabbitmq_versions';
|
54
|
+
var disqus_url = 'http://rdoc.info/github/ruby-amqp/amqp/master/file/docs/RabbitMQVersions.textile';
|
55
|
+
|
56
|
+
/* * * DON'T EDIT BELOW THIS LINE * * */
|
57
|
+
(function() {
|
58
|
+
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
59
|
+
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
|
60
|
+
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
61
|
+
})();
|
62
|
+
</script>
|
data/docs/Routing.textile
CHANGED
@@ -0,0 +1,116 @@
|
|
1
|
+
# @title Ruby AMQP gem: Running tests
|
2
|
+
|
3
|
+
h1. Running amqp gem test suite
|
4
|
+
|
5
|
+
|
6
|
+
h2. About this guide
|
7
|
+
|
8
|
+
This guide is for people who want to contribute to amqp gem development. It has no relevant information for those
|
9
|
+
who want to build applications using the library.
|
10
|
+
|
11
|
+
|
12
|
+
h2. Covered versions
|
13
|
+
|
14
|
+
Not applicable.
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
h2. Canonical repository
|
20
|
+
|
21
|
+
Since late 2010, the canonical amqp gem repository is at "github.com/ruby-amqp/amqp":https://github.com/ruby-amqp/amqp and *not tmm1/amqp*.
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
h2. Initial setup
|
26
|
+
|
27
|
+
amqp gem currently uses recent releases of RabbitMQ for automated tests. Broker installation is described in the {file:docs/GettingStarted.textile Getting started} guide
|
28
|
+
and on "rabbitmq.com":http://www.rabbitmq.com/install.html. Once the broker is running, the only other step is to run
|
29
|
+
|
30
|
+
<pre><code>
|
31
|
+
./bin/set_test_suite_realms_up.sh
|
32
|
+
</code></pre>
|
33
|
+
|
34
|
+
that will set up vhosts and users we test authentication and authorization against. Please note that the script uses `rabbitmqctl` tool
|
35
|
+
and in the server environment (for example, a virtual instance in the cloud) depending on your OS and/or distribution of choice, that tool
|
36
|
+
may or may not be accessible to your OS user, so pay attention to that.
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
h2. Dependencies
|
41
|
+
|
42
|
+
Dependencies are managed by Bundler. So begin with
|
43
|
+
|
44
|
+
<pre><code>
|
45
|
+
gem install bundler --version "~> 1.0.13"
|
46
|
+
</code></pre>
|
47
|
+
|
48
|
+
and then, from the root of the repository run
|
49
|
+
|
50
|
+
<pre><code>
|
51
|
+
bundle install
|
52
|
+
</code></pre>
|
53
|
+
|
54
|
+
and you are good to go.
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
h2. Running spec examples
|
60
|
+
|
61
|
+
During development, it is sufficient to just use
|
62
|
+
|
63
|
+
<pre><code>
|
64
|
+
bundle exec rspec -c ./spec
|
65
|
+
</code></pre>
|
66
|
+
|
67
|
+
or replace ./spec with an individual file you want to run.
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
h2. Continuous integration
|
73
|
+
|
74
|
+
CI happens in two steps:
|
75
|
+
|
76
|
+
* Clean up *.rbc files produced by "Rubinius":http://rubini.us.
|
77
|
+
* Run the whole test suite
|
78
|
+
|
79
|
+
For that, we use Rake:
|
80
|
+
|
81
|
+
<pre><code>
|
82
|
+
rake spec:ci
|
83
|
+
</code></pre>
|
84
|
+
|
85
|
+
Thanks to the excellent "Travis CI":http://travis-ci.org project, we run test suites across 5 Ruby implementations and 2 EventMachine versions, and can
|
86
|
+
add more implementations/versions so easily it still seems unreal.
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
h2. Tell us what you think!
|
92
|
+
|
93
|
+
Please take a moment and tell us what you think about this guide on "Ruby AMQP mailing list":http://groups.google.com/group/ruby-amqp:
|
94
|
+
what was unclear? what wasn't covered? maybe you don't like guide style or grammar and spelling are incorrect? Readers feedback is
|
95
|
+
key to making documentation better.
|
96
|
+
|
97
|
+
If mailing list communication is not an option for you for some reason, you can "contact guides author directly":mailto:michael@novemberain.com?subject=amqp%20gem%20documentation
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
<div id="disqus_thread"></div>
|
102
|
+
<script type="text/javascript">
|
103
|
+
/* * * CONFIGURATION VARIABLES * * */
|
104
|
+
var disqus_shortname = 'rubyamqpdocs'; // required: replace example with your forum shortname
|
105
|
+
|
106
|
+
var disqus_developer = 0; // set to 1 on local machine for testing comments
|
107
|
+
var disqus_identifier = 'amqp_running_tests_textile';
|
108
|
+
var disqus_url = 'http://rdoc.info/github/ruby-amqp/amqp/master/file/docs/RunningTests.textile';
|
109
|
+
|
110
|
+
/* * * DON'T EDIT BELOW THIS LINE * * */
|
111
|
+
(function() {
|
112
|
+
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
113
|
+
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
|
114
|
+
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
115
|
+
})();
|
116
|
+
</script>
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# @title Ruby AMQP gem: Troubleshooting and debugging AMQP applications
|
2
|
+
|
3
|
+
h1. Troubleshooting and debugging AMQP applications
|
4
|
+
|
5
|
+
|
6
|
+
h2. About this guide
|
7
|
+
|
8
|
+
This guide describes tools and strategies that help in troubleshooting and debugging applications that use AMQP in general and "Ruby AMQP gem":http://github.com/ruby-amqp/amqp
|
9
|
+
in particular.
|
10
|
+
|
11
|
+
|
12
|
+
h2. Covered versions
|
13
|
+
|
14
|
+
This guide covers "Ruby amqp gem":http://github.com/ruby-amqp/amqp v0.8.0 and later.
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
h2. First steps
|
19
|
+
|
20
|
+
Whenever something doesn't work, check the following things before asking on the mailing list:
|
21
|
+
|
22
|
+
* AMQP broker log.
|
23
|
+
* List of users in a particular vhost you are trying to connect.
|
24
|
+
* Network connectivity. We know, it's obvious, yet even experienced developers and devops engineers struggle with network access misconfigurations every once in a while.
|
25
|
+
* If EventMachine is started in a separate thread, make sure that isn't dead. If it is, this usually means there was an exception that caused it to terminate,
|
26
|
+
or environment it is running in "mixes threads and fork(2) system call":http://bit.ly/fork-and-threads.
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
h2. Inspecting AMQP broker log file
|
31
|
+
|
32
|
+
In this section we will cover typical problems that can be tracked down by reading AMQP broker log. We will use RabbitMQ as an example, however, different AMQP brokers
|
33
|
+
often log most of the same issues.
|
34
|
+
|
35
|
+
RabbitMQ logs abrupt TCP connection failures, timeouts, protocol version mismatches and so on.
|
36
|
+
If you are running RabbitMQ, log locations for various operating systems and distributions is documented in the "RabbitMQ installation guide":http://www.rabbitmq.com/install.html
|
37
|
+
|
38
|
+
On Mac OS X, RabbitMQ installed via Homebrew logs to $HOMEBREW_HOME/var/log/rabbitmq/rabbit@$HOSTNAME.log. For example, if you have Homebrew installed at /usr/local and
|
39
|
+
your hostname is giove, log will be at /usr/local/var/log/rabbitmq/rabbit@giove.log.
|
40
|
+
|
41
|
+
Here is what authentication failure looks like in RabbitMQ log:
|
42
|
+
|
43
|
+
<pre>
|
44
|
+
=ERROR REPORT==== 17-May-2011::17:37:58 ===
|
45
|
+
exception on TCP connection <0.4770.0> from 127.0.0.1:46551
|
46
|
+
{channel0_error,starting,
|
47
|
+
{amqp_error,access_refused,
|
48
|
+
"AMQPLAIN login refused: user 'pipeline_agent' - invalid credentials",
|
49
|
+
'connection.start_ok'}}
|
50
|
+
</pre>
|
51
|
+
|
52
|
+
This means that connection attempt with username pipeline_agent failed because credentials were invalid. If you are seeing this message, make sure username,
|
53
|
+
password *and vhost* are correct.
|
54
|
+
|
55
|
+
|
56
|
+
The following entry:
|
57
|
+
|
58
|
+
<pre>
|
59
|
+
=ERROR REPORT==== 17-May-2011::17:26:28 ===
|
60
|
+
exception on TCP connection <0.4201.62> from 10.8.0.30:57990
|
61
|
+
{bad_header,<<65,77,81,80,0,0,9,1>>}
|
62
|
+
</pre>
|
63
|
+
|
64
|
+
Means that client supports AMQP 0.9.1 but broker doesn't (RabbitMQ versions pre-2.0 only support AMQP 0.8, for example). If you are using amqp gem 0.8 or later
|
65
|
+
and seeing this entry in your broker log, you are connecting to AMQP broker that is too old to support this AMQP version. In case of RabbitMQ, make sure you run
|
66
|
+
version 2.0 or later.
|
67
|
+
|
68
|
+
TBD
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
h2. Testing network connection with AMQP broker using Telnet
|
73
|
+
|
74
|
+
One simple way to check network connection between a particular network node and a node running AMQP broker is to use `telnet`:
|
75
|
+
|
76
|
+
<pre>
|
77
|
+
telnet [host or ip] 5672
|
78
|
+
</pre>
|
79
|
+
|
80
|
+
then enter any random string of text and hit Enter. AMQP broker should immediately close down the connection. Here is an example
|
81
|
+
session:
|
82
|
+
|
83
|
+
<pre>
|
84
|
+
telnet localhost 5672
|
85
|
+
Connected to localhost.
|
86
|
+
Escape character is '^]'.
|
87
|
+
adjasd
|
88
|
+
AMQP Connection closed by foreign host.
|
89
|
+
</pre>
|
90
|
+
|
91
|
+
If instead Telnet exits after printing
|
92
|
+
|
93
|
+
<pre>
|
94
|
+
telnet: connect to address [host or ip]: Connection refused
|
95
|
+
telnet: Unable to connect to remote host
|
96
|
+
</pre>
|
97
|
+
|
98
|
+
then connection from the machine you are running Telnet tests on and AMQP broker fails. This can be due to many different reasons, but
|
99
|
+
it is a good idea to check these two things first:
|
100
|
+
|
101
|
+
* Firewall configuration for port 5672
|
102
|
+
* DNS setup (if hostname is used)
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
h2. Tell us what you think!
|
108
|
+
|
109
|
+
Please take a moment and tell us what you think about this guide on "Ruby AMQP mailing list":http://groups.google.com/group/ruby-amqp:
|
110
|
+
what was unclear? what wasn't covered? maybe you don't like guide style or grammar and spelling are incorrect? Readers feedback is
|
111
|
+
key to making documentation better.
|
112
|
+
|
113
|
+
If mailing list communication is not an option for you for some reason, you can "contact guides author directly":mailto:michael@novemberain.com?subject=amqp%20gem%20documentation
|
114
|
+
|
115
|
+
|
116
|
+
<div id="disqus_thread"></div>
|
117
|
+
<script type="text/javascript">
|
118
|
+
/* * * CONFIGURATION VARIABLES * * */
|
119
|
+
var disqus_shortname = 'rubyamqpdocs'; // required: replace example with your forum shortname
|
120
|
+
|
121
|
+
var disqus_developer = 0; // set to 1 on local machine for testing comments
|
122
|
+
var disqus_identifier = 'amqp_troubleshooting';
|
123
|
+
var disqus_url = 'http://rdoc.info/github/ruby-amqp/amqp/master/file/docs/Troubleshooting.textile';
|
124
|
+
|
125
|
+
/* * * DON'T EDIT BELOW THIS LINE * * */
|
126
|
+
(function() {
|
127
|
+
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
128
|
+
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
|
129
|
+
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
130
|
+
})();
|
131
|
+
</script>
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# @title Ruby AMQP gem: Using vendor-specific AMQP extensions
|
2
|
+
|
1
3
|
h1. Vendor-specific AMQP extensions support in amqp gem
|
2
4
|
|
3
5
|
h2. RabbitMQ extensions
|
@@ -40,3 +42,21 @@ what was unclear? what wasn't covered? maybe you don't like guide style or gramm
|
|
40
42
|
key to making documentation better.
|
41
43
|
|
42
44
|
If mailing list communication is not an option for you for some reason, you can "contact guides author directly":mailto:michael@novemberain.com?subject=amqp%20gem%20documentation
|
45
|
+
|
46
|
+
|
47
|
+
<div id="disqus_thread"></div>
|
48
|
+
<script type="text/javascript">
|
49
|
+
/* * * CONFIGURATION VARIABLES * * */
|
50
|
+
var disqus_shortname = 'rubyamqpdocs'; // required: replace example with your forum shortname
|
51
|
+
|
52
|
+
var disqus_developer = 0; // set to 1 on local machine for testing comments
|
53
|
+
var disqus_identifier = 'amqp_vendor_specific_extensions';
|
54
|
+
var disqus_url = 'http://rdoc.info/github/ruby-amqp/amqp/master/file/docs/VendorSpecificExtensions.textile';
|
55
|
+
|
56
|
+
/* * * DON'T EDIT BELOW THIS LINE * * */
|
57
|
+
(function() {
|
58
|
+
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
59
|
+
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
|
60
|
+
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
61
|
+
})();
|
62
|
+
</script>
|
@@ -13,8 +13,8 @@ puts "=> Channel#prefetch"
|
|
13
13
|
puts
|
14
14
|
AMQP.start(:host => 'localhost') do |connection|
|
15
15
|
ch = AMQP::Channel.new
|
16
|
-
ch.on_error do |
|
17
|
-
raise "Oops!
|
16
|
+
ch.on_error do |ch, channel_close|
|
17
|
+
raise "Oops! a channel-level exception: #{channel_close.inspect}"
|
18
18
|
end
|
19
19
|
ch.prefetch(1, false) do |_|
|
20
20
|
puts "qos callback has fired"
|
@@ -29,6 +29,6 @@ AMQP.start(:host => 'localhost') do |connection|
|
|
29
29
|
}
|
30
30
|
end
|
31
31
|
|
32
|
-
Signal.trap "INT", show_stopper
|
32
|
+
Signal.trap "INT", &show_stopper
|
33
33
|
EM.add_timer(1, show_stopper)
|
34
34
|
end
|
@@ -13,8 +13,8 @@ puts "=> Channel#prefetch"
|
|
13
13
|
puts
|
14
14
|
AMQP.start(:host => 'localhost') do |connection|
|
15
15
|
ch = AMQP::Channel.new
|
16
|
-
ch.on_error do |
|
17
|
-
raise "Oops!
|
16
|
+
ch.on_error do |ch, channel_close|
|
17
|
+
raise "Oops! a channel-level exception: #{channel_close.inspect}"
|
18
18
|
end
|
19
19
|
ch.prefetch(1, false)
|
20
20
|
|
@@ -16,7 +16,7 @@ AMQP.start("amqp://guest:guest@dev.rabbitmq.com:5672") do |connection, open_ok|
|
|
16
16
|
puts "Channel ##{channel.id} is now open!"
|
17
17
|
|
18
18
|
channel.on_error do |ch, close|
|
19
|
-
puts "Handling channel-level exception"
|
19
|
+
puts "Handling a channel-level exception: #{close.reply_text}"
|
20
20
|
end
|
21
21
|
|
22
22
|
EventMachine.add_timer(0.4) do
|
@@ -23,6 +23,7 @@ AMQP.start("amqp://guest:guest@dev.rabbitmq.com:5672") do |connection, open_ok|
|
|
23
23
|
puts "Channel ##{ch.id} is now open!"
|
24
24
|
end
|
25
25
|
ch2.on_error do |ch, close|
|
26
|
+
puts "close: #{close.inspect}"
|
26
27
|
puts "Handling channel-level exception on channel with id of #{ch.id} (ch2)"
|
27
28
|
end
|
28
29
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "bundler"
|
5
|
+
Bundler.setup
|
6
|
+
|
7
|
+
$:.unshift(File.expand_path("../../../lib", __FILE__))
|
8
|
+
|
9
|
+
require 'amqp'
|
10
|
+
|
11
|
+
EventMachine.run do
|
12
|
+
AMQP.connect(:host => '127.0.0.1', :port => 5672) do |connection|
|
13
|
+
puts "Connected to AMQP broker. Running #{AMQP::VERSION} version of the gem..."
|
14
|
+
|
15
|
+
|
16
|
+
connection.on_error do |conn, connection_close|
|
17
|
+
puts "Handling a connection-level exception: #{connection_close.reply_text}"
|
18
|
+
|
19
|
+
EventMachine.stop
|
20
|
+
end
|
21
|
+
|
22
|
+
# send_frame is NOT part of the public API, but it is public for entities like AMQ::Client::Channel
|
23
|
+
# and we use it here to trigger a connection-level exception. MK.
|
24
|
+
connection.send_frame(AMQ::Protocol::Connection::TuneOk.encode(1000, 1024 * 128 * 1024, 10))
|
25
|
+
end
|
26
|
+
end
|
@@ -32,12 +32,12 @@ AMQP.start("amqp://guest:guest@dev.rabbitmq.com:5672") do |connection, open_ok|
|
|
32
32
|
AMQP::Channel.new do |channel, open_ok|
|
33
33
|
puts "Channel ##{channel.id} is now open!"
|
34
34
|
|
35
|
-
channel.on_error do |ch,
|
35
|
+
channel.on_error do |ch, channel_close|
|
36
36
|
puts "Handling channel-level exception at instance level"
|
37
37
|
end
|
38
38
|
|
39
|
-
AMQP::Channel.on_error do |
|
40
|
-
puts "Handling channel-level exception at GLOBAL level. Jeez. Message is #{
|
39
|
+
AMQP::Channel.on_error do |ch, channel_close|
|
40
|
+
puts "Handling channel-level exception at GLOBAL level. Jeez. Message is #{channel_close.reply_text}"
|
41
41
|
end
|
42
42
|
|
43
43
|
EventMachine.add_timer(0.4) do
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "bundler"
|
5
|
+
Bundler.setup
|
6
|
+
|
7
|
+
$:.unshift(File.expand_path("../../../lib", __FILE__))
|
8
|
+
|
9
|
+
require 'amqp'
|
10
|
+
|
11
|
+
|
12
|
+
puts "=> Exchange#initialize example that uses :auto_delete => true"
|
13
|
+
puts
|
14
|
+
AMQP.start(:host => 'localhost', :port => 5673) do |connection|
|
15
|
+
AMQP::Channel.new do |channel, open_ok|
|
16
|
+
puts "Channel ##{channel.id} is now open!"
|
17
|
+
|
18
|
+
AMQP::Exchange.new(channel, :direct, "amqpgem.examples.xchange2", :auto_delete => false) do |exchange|
|
19
|
+
puts "#{exchange.name} is ready to go"
|
20
|
+
end
|
21
|
+
|
22
|
+
AMQP::Exchange.new(channel, :direct, "amqpgem.examples.xchange3", :auto_delete => true) do |exchange|
|
23
|
+
puts "#{exchange.name} is ready to go"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
show_stopper = Proc.new do
|
28
|
+
$stdout.puts "Stopping..."
|
29
|
+
|
30
|
+
connection.close {
|
31
|
+
EM.stop { exit }
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
Signal.trap "INT", show_stopper
|
36
|
+
EM.add_timer(2, show_stopper)
|
37
|
+
end
|