arvicco-amqp 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ *.rbc
3
+ ~*
4
+ #*
data/HISTORY ADDED
@@ -0,0 +1,7 @@
1
+ == 0.6.7 / 2010-11-03
2
+
3
+ * Forked tmm1/amqp at Github
4
+
5
+ == 0.6.8 / 2010-11-03
6
+
7
+ * Additional improvements from latest forks added
data/README.md ADDED
@@ -0,0 +1,155 @@
1
+ What AMQP gem is
2
+ ================
3
+
4
+ Simple asynchronous AMQP driver for Ruby/EventMachine
5
+ This library works with Ruby 1.8, Ruby 1.9, JRuby and Rubinius,
6
+ and is licensed under [the Ruby License](http://www.ruby-lang.org/en/LICENSE.txt).
7
+
8
+ This library was tested primarily with RabbitMQ, although it should be compatible with any
9
+ server implementing the [AMQP 0-8 spec](http://www.amqp.org/confluence/download/attachments/720900/amqp0-8.pdf).
10
+
11
+
12
+ This fork of AMQP
13
+ =================
14
+
15
+ Contains following improvements:
16
+ * Support for setting extended headers in MQ::Exchange#publish. Particularly useful for :reply_to for RPC.
17
+ * Multibyte character support (Ruby 1.9) in MQ::Exchange#publish.
18
+ * MQ::Queue only wraps headers with new MQ::Headers if they are not nil. This allows pops to tell more easily when they've requested a message from an empty queue.
19
+ * Support for receiving Headers with zero-size data packets. Such contents with no body frames are totally legit if indicated header size is zero.
20
+
21
+
22
+ Getting started
23
+ ===============
24
+
25
+ To use examples with RabbitMQ, first [install the broker](http://www.rabbitmq.com/install.html).
26
+ If you have Mercurial and Erlang/OTP installed, here is how to do it in 4 lines:
27
+
28
+ hg clone http://hg.rabbitmq.com/rabbitmq-codegen
29
+ hg clone http://hg.rabbitmq.com/rabbitmq-server
30
+ cd rabbitmq-server
31
+ make run
32
+
33
+ Then have a look at the various bundled examples:
34
+
35
+ ruby examples/mq/pingpong.rb # 1-1 communication using amq.direct
36
+ ruby examples/mq/clock.rb # 1-N communication using amq.fanout
37
+ ruby examples/mq/stocks.rb # 1-subscriber communication using amq.topic
38
+
39
+ ruby examples/mq/multiclock.rb # header based routing (new rabbitmq feature)
40
+ ruby examples/mq/ack.rb # using ack
41
+ ruby examples/mq/pop.rb # pop off messages one at a time
42
+
43
+ ruby examples/mq/hashtable.rb # simple async rpc layer
44
+ ruby examples/mq/primes.rb 4 # parallelized prime number generation
45
+ ruby examples/mq/logger.rb # simple logging api
46
+
47
+ For high level API documentation see MQ class.
48
+ For more details into the lower level AMQP client API, run the simple client example:
49
+
50
+ ruby examples/amqp/simple.rb # low-level AMQP api
51
+ ruby examples/mq/internal.rb # low-level Queue/Exchange api
52
+
53
+ Or refer to protocol/doc.txt, which enumerates packets sent between a server and client
54
+ during a typical session, in both binary and decoded formats.
55
+
56
+ How to use AMQP gem with Ruby on Rails, Merb, Sinatra and other web frameworks
57
+ ==============================================================================
58
+
59
+ To use AMQP gem from web applications, you would need to have EventMachine reactor running.
60
+ If you use [Thin](http://code.macournoyer.com/thin/), you are set: Thin uses EventMachine under
61
+ the hook.
62
+
63
+ With other web servers, you need to start EventMachine reactor in it's own thread like this:
64
+
65
+ Thread.new { EM.run }
66
+
67
+ because otherwise EventMachine will block current thread. Then connect to AMQP broker:
68
+
69
+ AMQP.connect(:host => "localhost", :user => "guest", :pass => "guest", :vhost => "/")
70
+
71
+ In a Ruby on Rails app, probably the best place for this code is initializer
72
+ (like config/initializers/amqp.rb). For Merb apps, it is config/init.rb. For
73
+ Sinatra and pure Rack applications, place it next to other configuration
74
+ code.
75
+
76
+ Same separate thread technique can be used to make EventMachine play nicely with other
77
+ libraries that would block current thread (like [File::Tail](http://rubygems.org/gems/file-tail)).
78
+
79
+ AMQP gem mailing list
80
+ ==============================
81
+
82
+ * [AMQP gem mailing list](http://groups.google.com/group/ruby-amqp)
83
+ * [AMQP gem at GitHub](http://github.com/tmm1/amqp)
84
+ * [AMQP gem at Gemcutter](http://rubygems.org/gems/amqp)
85
+
86
+ Running specifications suite
87
+ ============================
88
+
89
+ To run the test suite make sure you have [bacon](http://gemcutter.org/gems/bacon) gem installed and run:
90
+
91
+ rake spec
92
+
93
+ The lib/amqp/spec.rb file is generated automatically based on the [AMQP specification](http://www.amqp.org/confluence/display/AMQP/AMQP+Specification). To generate it:
94
+
95
+ rake codegen
96
+
97
+ Credits and more information
98
+ ============================
99
+
100
+ (c) 2008—2010 [Aman Gupta](http://github.com/tmm1) (tmm1)
101
+
102
+ This project was inspired by [py-amqplib](http://barryp.org/software/py-amqplib/), [rabbitmq](http://rabbitmq.com), [qpid](http://qpid.apache.org/) and [rubbyt](http://github.com/rubbyt/rubbyt).
103
+ Special thanks to Dmitriy Samovskiy, Ben Hood and Tony Garnock-Jones.
104
+
105
+ AMQP brokers
106
+ ------------
107
+
108
+ * [RabbitMQ](http://rabbitmq.com) (Rabbit Technologies, Erlang/OTP, MPL)
109
+ * [ZeroMQ](http://www.zeromq.org) (iMatix/FastMQ/Intel, C++, GPL3)
110
+ * [OpenAMQ](http://openamq.org) (iMatix, C, GPL2)
111
+ * [ActiveMQ](http://activemq.apache.org) (Apache Foundation, Java, Apache2)
112
+
113
+ AMQP resources
114
+ --------------
115
+
116
+ * Steve Vinoski [explains AMQP](http://steve.vinoski.net/pdf/IEEE-Advanced_Message_Queuing_Protocol.pdf) in his column, Towards Integration
117
+
118
+ * John O'Hara on [the history of AMQP](http://www.acmqueue.org/modules.php?name=Content&pa=showpage&pid=485)
119
+
120
+ * Dmitriy's [presentation on RabbitMQ/AMQP](http://somic-org.homelinux.org/blog/2008/07/31/slides-for-my-amqprabbitmq-talk/)
121
+
122
+ * ZeroMQ's [analysis of the messaging technology market](http://www.zeromq.org/whitepapers:market-analysis)
123
+
124
+ * Pieter Hintjens's [background to AMQP](http://www.openamq.org/doc:amqp-background)
125
+
126
+ * Barry Pederson's [py-amqplib](http://barryp.org/software/py-amqplib/)
127
+
128
+ * Ben Hood on [writing an AMQP client](http://hopper.squarespace.com/blog/2008/6/21/build-your-own-amqp-client.html)
129
+
130
+ * Dmitriy Samovskiy introduces [Ruby + QPid + RabbitMQ](http://somic-org.homelinux.org/blog/2008/06/24/ruby-amqp-rabbitmq-example/)
131
+
132
+ * Ben Hood's [as3-amqp](http://github.com/0x6e6562/as3-amqp) ([two](http://hopper.squarespace.com/blog/2008/7/4/server-side-as3.html), [three](http://hopper.squarespace.com/blog/2008/3/24/as3-amqp-client-first-cut.html))
133
+
134
+ * RabbitMQ's [AMQP protocol code generator](http://hg.rabbitmq.com/rabbitmq-codegen/)
135
+
136
+ * Erlang Exchange [presentation on the implementation of RabbitMQ](http://skillsmatter.com/podcast/erlang/presenting-rabbitmq-an-erlang-based-implementatio-nof-amqp) (and on the [LShift blog](http://www.lshift.net/blog/2008/07/01/slides-from-our-erlang-exchange-talk))
137
+
138
+ * Jonathan Conway's series on RabbitMQ and using it with Ruby and Merb: [One](http://jaikoo.com/2007/9/4/didn-t-you-get-the-memo), [Two](http://jaikoo.com/2008/2/29/friday-round-up-2008-02-29), [Three](http://jaikoo.com/2008/3/14/oh-hai-rabbitmq), [Four](http://jaikoo.com/2008/3/20/daemonize-rabbitmq)
139
+
140
+ * Open Enterprise's series on messaging middleware and AMQP: [Part 1](http://www1.interopsystems.com/analysis/can-amqp-break-ibms-mom-monopoly-part-1.html), [Part 2](http://www1.interopsystems.com/analysis/can-amqp-break-ibms-mom-monopoly-part-2.html), [Part 3](http://www1.interopsystems.com/analysis/can-amqp-break-ibms-mom-monopoly-part-3.html)
141
+
142
+ Messaging and distributed systems resources
143
+ -------------------------------------------
144
+
145
+ * [A Critique of the Remote Procedure Call Paradigm](http://www.cs.vu.nl/~ast/publications/euteco-1988.pdf)
146
+
147
+ * [A Note on Distributed Computing](http://research.sun.com/techrep/1994/smli_tr-94-29.pdf)
148
+
149
+ * [Convenience Over Correctness](http://steve.vinoski.net/pdf/IEEE-Convenience_Over_Correctness.pdf)
150
+
151
+ * [Metaprotocol Taxonomy and Communications Patterns](http://hessian.caucho.com/doc/metaprotocol-taxonomy.xtp)
152
+
153
+ * Joe Armstrong on [Erlang messaging vs RPC](http://armstrongonsoftware.blogspot.com/2008/05/road-we-didnt-go-down.html)
154
+
155
+ * [SEDA: scalable internet services using message queues](http://www.eecs.harvard.edu/~mdw/papers/seda-sosp01.pdf)
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rake'
2
+ require 'pathname'
3
+
4
+ BASE_PATH = Pathname.new(__FILE__).dirname
5
+ LIB_PATH = BASE_PATH + 'lib'
6
+ PKG_PATH = BASE_PATH + 'pkg'
7
+ DOC_PATH = BASE_PATH + 'rdoc'
8
+
9
+ $LOAD_PATH.unshift LIB_PATH.to_s unless $LOAD_PATH.include? LIB_PATH.to_s
10
+
11
+ require 'amqp/version'
12
+
13
+ NAME = 'arvicco-amqp'
14
+ CLASS_NAME = AMQP
15
+ VERSION = CLASS_NAME::VERSION
16
+
17
+ # Load rakefile tasks
18
+ Dir['tasks/*.rake'].sort.each { |file| load file }
19
+
20
+ desc "Generate AMQP specification classes"
21
+ task :codegen do
22
+ sh 'ruby protocol/codegen.rb > lib/amqp/spec.rb'
23
+ sh 'ruby lib/amqp/spec.rb'
24
+ end
25
+
26
+ desc "Run spec suite (uses bacon gem)"
27
+ task :test do
28
+ sh 'bacon lib/amqp.rb'
29
+ end
data/TODO ADDED
@@ -0,0 +1,30 @@
1
+ - breaks with header values that are nil (deleting nil headers in Exchange#publish for now)
2
+
3
+ - generate amqp/spec.rb from original xml spec
4
+ - add peek and pop to queues
5
+ - use rabbitmq generated consumer tag from basic.consume-ok reply
6
+
7
+ - allow temporary queues with amq.queue(nil) syntax (use uuids)
8
+ - use as temp queue in rpc
9
+ - use uuids for message ids in rpc
10
+
11
+ - add ack/completed responses for messages
12
+ - deleting queues/bindings/exchanges
13
+ + queue.unbind
14
+ - queue.remove or queue.close or queue.delete
15
+ - exchange.remove
16
+ - rpc.remove
17
+
18
+ - handle errors and exceptions
19
+ binding to a non-existent (or not yet created in clock.rb) exchange
20
+ #<AMQP::Protocol::Channel::Close:0x11d35d4
21
+ @class_id=50,
22
+ @debug=1,
23
+ @method_id=20,
24
+ @reply_code=404,
25
+ @reply_text="NOT_FOUND - no exchange 'clock' in vhost '/'">>]
26
+
27
+ - handle connection.redirect during connect (for rabbitmq in distributed mode) [or just set insist to true]
28
+
29
+ - add amq.queue('name').size{ |num| "#{num} messages in the queue" } (send declare passive, look at declare-ok response)
30
+ - clean up MQ.default on disconnect
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.6.8
@@ -0,0 +1,2 @@
1
+ == Ping Pong Example
2
+ :include: mq/pingpong.rb
@@ -0,0 +1,2 @@
1
+ == Clock Example
2
+ :include: mq/clock.rb
@@ -0,0 +1,2 @@
1
+ == Stocks Example
2
+ :include: mq/stocks.rb
@@ -0,0 +1,2 @@
1
+ == Muti-format Clock Example
2
+ :include: mq/multiclock.rb
@@ -0,0 +1,2 @@
1
+ == Ack Example
2
+ :include: mq/ack.rb
@@ -0,0 +1,2 @@
1
+ == Pop Example
2
+ :include: mq/pop.rb
@@ -0,0 +1,2 @@
1
+ == HashTable RPC Example
2
+ :include: mq/hashtable.rb
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arvicco-amqp
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 8
10
+ version: 0.6.8
11
+ platform: ruby
12
+ authors:
13
+ - Aman Gupta
14
+ - Arvicco
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-11-03 00:00:00 +03:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: eventmachine
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 39
31
+ segments:
32
+ - 0
33
+ - 12
34
+ - 4
35
+ version: 0.12.4
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: bacon
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 31
47
+ segments:
48
+ - 0
49
+ - 0
50
+ - 0
51
+ version: 0.0.0
52
+ type: :development
53
+ version_requirements: *id002
54
+ description: An implementation of the AMQP protocol in Ruby/EventMachine. Fork of original tmm1/amqp with improvements (see README).
55
+ email: arvitallian@gmail.com
56
+ executables: []
57
+
58
+ extensions: []
59
+
60
+ extra_rdoc_files:
61
+ - README.md
62
+ - HISTORY
63
+ - doc/EXAMPLE_01_PINGPONG
64
+ - doc/EXAMPLE_02_CLOCK
65
+ - doc/EXAMPLE_03_STOCKS
66
+ - doc/EXAMPLE_04_MULTICLOCK
67
+ - doc/EXAMPLE_05_ACK
68
+ - doc/EXAMPLE_05_POP
69
+ - doc/EXAMPLE_06_HASHTABLE
70
+ files:
71
+ - Rakefile
72
+ - README.md
73
+ - VERSION
74
+ - TODO
75
+ - HISTORY
76
+ - .gitignore
77
+ - doc/EXAMPLE_01_PINGPONG
78
+ - doc/EXAMPLE_02_CLOCK
79
+ - doc/EXAMPLE_03_STOCKS
80
+ - doc/EXAMPLE_04_MULTICLOCK
81
+ - doc/EXAMPLE_05_ACK
82
+ - doc/EXAMPLE_05_POP
83
+ - doc/EXAMPLE_06_HASHTABLE
84
+ has_rdoc: true
85
+ homepage: http://github.com/arvicco/amqp
86
+ licenses: []
87
+
88
+ post_install_message:
89
+ rdoc_options:
90
+ - --include=examples
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ requirements: []
112
+
113
+ rubyforge_project:
114
+ rubygems_version: 1.3.7
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: Fork of original tmm1/amqp with some tweaks.
118
+ test_files: []
119
+