tmm1-amqp 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/emfork.rb ADDED
@@ -0,0 +1,67 @@
1
+ EMFORK = $0 == __FILE__
2
+
3
+ if EMFORK
4
+ require 'rubygems'
5
+ end
6
+
7
+ require 'eventmachine'
8
+
9
+ # helper to fork off EM reactors
10
+ def EM.fork num = 1, &blk
11
+ unless @forks
12
+ trap('CHLD'){
13
+ pid = Process.wait
14
+ p [:pid, pid, :died] if EMFORK
15
+ block = @forks.delete(pid)
16
+ EM.fork(1, &block)
17
+ }
18
+
19
+ trap('EXIT'){
20
+ p [:pid, Process.pid, :exit] if EMFORK
21
+ @forks.keys.each{ |pid|
22
+ p [:pid, Process.pid, :killing, pid] if EMFORK
23
+ Process.kill('USR1', pid)
24
+ }
25
+ }
26
+
27
+ @forks = {}
28
+ end
29
+
30
+ num.times do
31
+ pid = EM.fork_reactor do
32
+ p [:pid, Process.pid, :started] if EMFORK
33
+
34
+ trap('USR1'){ EM.stop_event_loop }
35
+ trap('CHLD'){}
36
+ trap('EXIT'){}
37
+
38
+ blk.call
39
+ end
40
+
41
+ @forks[pid] = blk
42
+ p [:children, EM.forks] if EMFORK
43
+ end
44
+ end
45
+
46
+ def EM.forks
47
+ @forks.keys
48
+ end
49
+
50
+ if EMFORK
51
+ p 'starting reactor'
52
+
53
+ trap('INT'){ EM.stop_event_loop }
54
+
55
+ EM.run{
56
+ p [:parent, Process.pid]
57
+
58
+ EM.fork(2){
59
+ EM.add_periodic_timer(1) do
60
+ p [:fork, Process.pid, :ping]
61
+ end
62
+ }
63
+
64
+ }
65
+
66
+ p 'reactor stopped'
67
+ end
data/lib/mq.rb ADDED
@@ -0,0 +1,133 @@
1
+ $:.unshift File.expand_path(File.dirname(File.expand_path(__FILE__)))
2
+ require 'amqp'
3
+
4
+ class MQ
5
+ %w[ exchange queue rpc ].each do |file|
6
+ require "mq/#{file}"
7
+ end
8
+
9
+ class << self
10
+ @logging = false
11
+ attr_accessor :logging
12
+ end
13
+ end
14
+
15
+ class MQ
16
+ include AMQP
17
+ include EM::Deferrable
18
+
19
+ def initialize
20
+ conn.callback{ |c|
21
+ @channel = c.add_channel(self)
22
+ send Protocol::Channel::Open.new
23
+ }
24
+ end
25
+ attr_reader :channel
26
+
27
+ def process_frame frame
28
+ log :received, frame
29
+
30
+ case frame
31
+ when Frame::Header
32
+ @header = frame.payload
33
+ @body = ''
34
+
35
+ when Frame::Body
36
+ @body << frame.payload
37
+ if @body.length >= @header.size
38
+ @consumer.receive @header, @body
39
+ @body = ''
40
+ end
41
+
42
+ when Frame::Method
43
+ case method = frame.payload
44
+ when Protocol::Channel::OpenOk
45
+ send Protocol::Access::Request.new(:realm => '/data',
46
+ :read => true,
47
+ :write => true,
48
+ :active => true)
49
+
50
+ when Protocol::Access::RequestOk
51
+ @ticket = method.ticket
52
+ succeed
53
+
54
+ when Protocol::Basic::Deliver
55
+ @header = nil
56
+ @body = ''
57
+ @consumer = queues[ method.consumer_tag ]
58
+ end
59
+ end
60
+ end
61
+
62
+ def send data
63
+ data.ticket = @ticket if @ticket and data.respond_to? :ticket
64
+ conn.callback{ |c|
65
+ log :sending, data
66
+ c.send data, :channel => @channel
67
+ }
68
+ end
69
+
70
+ %w[ direct topic fanout ].each do |type|
71
+ class_eval %[
72
+ def #{type} name = 'amq.#{type}', opts = {}
73
+ exchanges[name] ||= Exchange.new(self, :#{type}, name, opts)
74
+ end
75
+ ]
76
+ end
77
+
78
+ def queue name, opts = {}
79
+ queues[name] ||= Queue.new(self, name, opts)
80
+ end
81
+
82
+ def rpc name, obj = nil
83
+ rpcs[name] ||= RPC.new(self, name, obj)
84
+ end
85
+
86
+ private
87
+
88
+ def log *args
89
+ return unless MQ.logging
90
+ pp args
91
+ puts
92
+ end
93
+
94
+ # keep track of proxy objects
95
+
96
+ def exchanges
97
+ @exchanges ||= {}
98
+ end
99
+
100
+ def queues
101
+ @queues ||= {}
102
+ end
103
+
104
+ def rpcs
105
+ @rcps ||= {}
106
+ end
107
+
108
+ # create a class level connection on demand
109
+
110
+ def connection
111
+ @@connection ||= AMQP.start
112
+ end
113
+ alias :conn :connection
114
+ end
115
+
116
+ # convenience wrapper for thread-local MQ object
117
+
118
+ class MQ
119
+ def MQ.default
120
+ Thread.current[:mq] ||= MQ.new
121
+ end
122
+
123
+ def MQ.method_missing meth, *args, &blk
124
+ MQ.default.__send__(meth, *args, &blk)
125
+ end
126
+ end
127
+
128
+ # unique identifier
129
+ class MQ
130
+ def MQ.id
131
+ Thread.current[:mq_id] ||= "#{`hostname`.strip}-#{Process.pid}-#{Thread.current.object_id}"
132
+ end
133
+ end
@@ -0,0 +1,36 @@
1
+ class MQ
2
+ class Exchange
3
+ include AMQP
4
+
5
+ def initialize mq, type, name, opts = {}
6
+ @mq = mq
7
+ @type, @name = type, name
8
+ @key = opts[:key]
9
+
10
+ @mq.callback{
11
+ @mq.send Protocol::Exchange::Declare.new({ :exchange => name,
12
+ :type => type,
13
+ :nowait => true }.merge(opts))
14
+ } unless name == "amq.#{type}" or name == ''
15
+ end
16
+ attr_reader :name, :type, :key
17
+
18
+ def publish data, opts = {}
19
+ @mq.callback{
20
+ EM.next_tick do
21
+ @mq.send Protocol::Basic::Publish.new({ :exchange => name,
22
+ :routing_key => opts.delete(:key) || @key }.merge(opts))
23
+
24
+ data = data.to_s
25
+
26
+ @mq.send Protocol::Header.new(Protocol::Basic,
27
+ data.length, { :content_type => 'application/octet-stream',
28
+ :delivery_mode => 1,
29
+ :priority => 0 }.merge(opts))
30
+ @mq.send Frame::Body.new(data)
31
+ end
32
+ }
33
+ self
34
+ end
35
+ end
36
+ end
data/lib/mq/queue.rb ADDED
@@ -0,0 +1,52 @@
1
+ class MQ
2
+ class Queue
3
+ include AMQP
4
+
5
+ def initialize mq, name, opts = {}
6
+ @mq = mq
7
+ @name = name
8
+ @mq.callback{
9
+ @mq.send Protocol::Queue::Declare.new({ :queue => name,
10
+ :nowait => true }.merge(opts))
11
+ }
12
+ end
13
+ attr_reader :name
14
+
15
+ def bind exchange, opts = {}
16
+ @mq.callback{
17
+ @mq.send Protocol::Queue::Bind.new({ :queue => name,
18
+ :exchange => exchange.respond_to?(:name) ? exchange.name : exchange,
19
+ :routing_key => opts.delete(:key),
20
+ :nowait => true }.merge(opts))
21
+ }
22
+ self
23
+ end
24
+
25
+ def subscribe opts = {}, &blk
26
+ @on_msg = blk
27
+ @mq.callback{
28
+ @mq.send Protocol::Basic::Consume.new({ :queue => name,
29
+ :consumer_tag => name,
30
+ :no_ack => true,
31
+ :nowait => true }.merge(opts))
32
+ }
33
+ self
34
+ end
35
+
36
+ def publish data, opts = {}
37
+ exchange.publish(data, opts)
38
+ end
39
+
40
+ def receive headers, body
41
+ if @on_msg
42
+ @on_msg.call *(@on_msg.arity == 1 ? [body] : [headers, body])
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ def exchange
49
+ @exchange ||= Exchange.new(@mq, :direct, '', :key => name)
50
+ end
51
+ end
52
+ end
data/lib/mq/rpc.rb ADDED
@@ -0,0 +1,51 @@
1
+ require 'emfork'
2
+
3
+ unless defined?(BlankSlate)
4
+ class BlankSlate < BasicObject; end if defined?(BasicObject)
5
+
6
+ class BlankSlate
7
+ instance_methods.each { |m| undef_method m unless m =~ /^__/ }
8
+ end
9
+ end
10
+
11
+ class MQ
12
+ class RPC < BlankSlate
13
+ def initialize mq, queue, obj = nil
14
+ @mq = mq
15
+
16
+ if obj
17
+ @obj = case obj
18
+ when ::Class
19
+ obj.new
20
+ when ::Module
21
+ (::Class.new do include(obj) end).new
22
+ else
23
+ obj
24
+ end
25
+
26
+ @mq.queue(queue).subscribe{ |info, request|
27
+ method, *args = ::Marshal.load(request)
28
+ ret = @obj.__send__(method, *args)
29
+
30
+ if info.reply_to
31
+ @mq.queue(info.reply_to).publish(::Marshal.dump(ret), :key => info.reply_to, :message_id => info.message_id)
32
+ end
33
+ }
34
+ else
35
+ @callbacks ||= {}
36
+ @queue = @mq.queue(@name = 'some random identifier for me').subscribe{|info, msg|
37
+ if blk = @callbacks.delete(info.message_id)
38
+ blk.call ::Marshal.load(msg)
39
+ end
40
+ }
41
+ @remote = @mq.queue(queue)
42
+ end
43
+ end
44
+
45
+ def method_missing meth, *args, &blk
46
+ message_id = "random message id #{::Kernel.rand(999_999_999_999)}"
47
+ @callbacks[message_id] = blk if blk
48
+ @remote.publish(::Marshal.dump([meth, *args]), :reply_to => blk ? @name : nil, :message_id => message_id)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,606 @@
1
+ /*
2
+ Copyright (c) 2008 John Leuner
3
+
4
+ Permission is hereby granted, free of charge, to any person
5
+ obtaining a copy of this file (the "Software"), to deal in the
6
+ Software without restriction, including without limitation the
7
+ rights to use, copy, modify, merge, publish, distribute,
8
+ sublicense, and/or sell copies of the Software, and to permit
9
+ persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ Class information entered from amqp_xml0-8.pdf and domain types from amqp-xml-doc0-9.pdf
25
+
26
+ b3cb053f15e7b98808c0ccc67f23cb3e amqp_xml0-8.pdf
27
+ http://www.twiststandards.org/index.php?option=com_docman&task=cat_view&gid=28&&Itemid=90
28
+ 8444db91e2949dbecfb2585e9eef6d64 amqp-xml-doc0-9.pdf
29
+ https://jira.amqp.org/confluence/download/attachments/720900/amqp-xml-doc0-9.pdf?version=1
30
+ */
31
+
32
+ {
33
+ "name": "AMQP",
34
+ "major-version": 8,
35
+ "minor-version": 0,
36
+ "port": 5672,
37
+
38
+ "domains": [
39
+ ["access-ticket", "short"],
40
+ ["bit", "bit"],
41
+ ["channel-id", "longstr"],
42
+ ["class-id", "short"],
43
+ ["consumer-tag", "shortstr"],
44
+ ["delivery-tag", "longlong"],
45
+ ["destination", "shortstr"],
46
+ ["duration", "longlong"],
47
+ ["exchange-name", "shortstr"],
48
+ ["known-hosts", "shortstr"],
49
+ ["long", "long"],
50
+ ["longlong", "longlong"],
51
+ ["longstr", "longstr"],
52
+ ["method-id", "short"],
53
+ ["no-ack", "bit"],
54
+ ["no-local", "bit"],
55
+ ["octet", "octet"],
56
+ ["offset", "longlong"],
57
+ ["path", "shortstr"],
58
+ ["peer-properties", "table"],
59
+ ["queue-name", "shortstr"],
60
+ ["redelivered", "bit"],
61
+ ["reference", "longstr"],
62
+ ["reject-code", "short"],
63
+ ["reject-text", "shortstr"],
64
+ ["reply-code", "short"],
65
+ ["reply-text", "shortstr"],
66
+ ["security-token", "longstr"],
67
+ ["short", "short"],
68
+ ["shortstr", "shortstr"],
69
+ ["table", "table"],
70
+ ["timestamp", "timestamp"]
71
+ ],
72
+
73
+ "constants": [
74
+ {"name": "FRAME-METHOD", "value": 1},
75
+ {"name": "FRAME-HEADER", "value": 2},
76
+ {"name": "FRAME-BODY", "value": 3},
77
+ {"name": "FRAME-OOB-METHOD", "value": 4},
78
+ {"name": "FRAME-OOB-HEADER", "value": 5},
79
+ {"name": "FRAME-OOB-BODY", "value": 6},
80
+ {"name": "FRAME-TRACE", "value": 7},
81
+ {"name": "FRAME-HEARTBEAT", "value": 8},
82
+ {"name": "FRAME-MIN-SIZE", "value": 4096},
83
+ {"name": "FRAME-END", "value": 206},
84
+ {"name": "REPLY-SUCCESS", "value": 200},
85
+ {"name": "NOT-DELIVERED", "value": 310, "class": "soft-error"},
86
+ {"name": "CONTENT-TOO-LARGE", "value": 311, "class": "soft-error"},
87
+ {"name": "NO-ROUTE", "value": 312, "class": "soft-error"},
88
+ {"name": "NO-CONSUMERS", "value": 313, "class": "soft-error"},
89
+ {"name": "ACCESS-REFUSED", "value": 403, "class": "soft-error"},
90
+ {"name": "NOT-FOUND", "value": 404, "class": "soft-error"},
91
+ {"name": "RESOURCE-LOCKED", "value": 405, "class": "soft-error"},
92
+ {"name": "PRECONDITION-FAILED", "value": 406, "class": "soft-error"},
93
+ {"name": "CONNECTION-FORCED", "value": 320, "class": "hard-error"},
94
+ {"name": "INVALID-PATH", "value": 402, "class": "hard-error"},
95
+ {"name": "FRAME-ERROR", "value": 501, "class": "hard-error"},
96
+ {"name": "SYNTAX-ERROR", "value": 502, "class": "hard-error"},
97
+ {"name": "COMMAND-INVALID", "value": 503, "class": "hard-error"},
98
+ {"name": "CHANNEL-ERROR", "value": 504, "class": "hard-error"},
99
+ {"name": "RESOURCE-ERROR", "value": 506, "class": "hard-error"},
100
+ {"name": "NOT-ALLOWED", "value": 530, "class": "hard-error"},
101
+ {"name": "NOT-IMPLEMENTED", "value": 540, "class": "hard-error"},
102
+ {"name": "INTERNAL-ERROR", "value": 541, "class": "hard-error"}
103
+ ],
104
+
105
+ "classes": [
106
+ {
107
+ "id": 10,
108
+ "methods": [{"id": 10,
109
+ "arguments": [{"type": "octet", "name": "version-major"},
110
+ {"type": "octet", "name": "version-minor"},
111
+ {"domain": "peer-properties", "name": "server properties"},
112
+ {"type": "longstr", "name": "mechanisms"},
113
+ {"type": "longstr", "name": "locales"}],
114
+ "name": "start"},
115
+ {"id": 11,
116
+ "arguments": [{"domain": "peer-properties", "name": "client-properties"},
117
+ {"type": "shortstr", "name": "mechanism"},
118
+ {"type": "longstr", "name": "response"},
119
+ {"type": "shortstr", "name": "locale"}],
120
+ "name": "start-ok"},
121
+ {"id": 20,
122
+ "arguments": [{"type": "longstr", "name": "challenge"}],
123
+ "name": "secure"},
124
+ {"id": 21,
125
+ "arguments": [{"type": "longstr", "name": "response"}],
126
+ "name": "secure-ok"},
127
+ {"id": 30,
128
+ "arguments": [{"type": "short", "name": "channel-max"},
129
+ {"type": "long", "name": "frame-max"},
130
+ {"type": "short", "name": "heartbeat"}],
131
+ "name": "tune"},
132
+ {"id": 31,
133
+ "arguments": [{"type": "short", "name": "channel-max"},
134
+ {"type": "long", "name": "frame-max"},
135
+ {"type": "short", "name": "heartbeat"}],
136
+ "name": "tune-ok"},
137
+ {"id": 40,
138
+ "arguments": [{"type": "shortstr", "name": "virtual-host"},
139
+ {"type": "shortstr", "name": "capabilities"},
140
+ {"type": "bit", "name": "insist"}],
141
+ "name": "open"},
142
+ {"id": 41,
143
+ "arguments": [{"type": "shortstr", "name": "known-hosts"}],
144
+ "name": "open-ok"},
145
+ {"id": 50,
146
+ "arguments": [{"type": "shortstr", "name": "host"},
147
+ {"type": "shortstr", "name": "known-hosts"}],
148
+ "name": "redirect"},
149
+ {"id": 60,
150
+ "arguments": [{"type": "short", "name": "reply-code"},
151
+ {"type": "shortstr", "name": "reply-text"},
152
+ {"type": "short", "name": "class-id"},
153
+ {"type": "short", "name": "method-id"}],
154
+ "name": "close"},
155
+ {"id": 61,
156
+ "arguments": [],
157
+ "name": "close-ok"}],
158
+ "name": "connection",
159
+ "properties": []
160
+ },
161
+ {
162
+ "id": 20,
163
+ "methods": [{"id": 10,
164
+ "arguments": [{"type": "shortstr", "name": "out-of-band"}],
165
+ "name": "open"},
166
+ {"id": 11,
167
+ "arguments": [],
168
+ "name": "open-ok"},
169
+ {"id": 20,
170
+ "arguments": [{"type": "bit", "name": "active"}],
171
+ "name": "flow"},
172
+ {"id": 21,
173
+ "arguments": [{"type": "bit", "name": "active"}],
174
+ "name": "flow-ok"},
175
+ {"id": 30,
176
+ "arguments": [{"type": "short", "name": "reply-code"},
177
+ {"type": "shortstr", "name": "reply-text"},
178
+ {"type": "table", "name": "details"}],
179
+ "name": "alert"},
180
+ {"id": 40,
181
+ "arguments": [{"type": "short", "name": "reply-code"},
182
+ {"type": "shortstr", "name": "reply-text"},
183
+ {"type": "short", "name": "class-id"},
184
+ {"type": "short", "name": "method-id"}],
185
+ "name": "close"},
186
+ {"id": 41,
187
+ "arguments": [],
188
+ "name": "close-ok"}],
189
+ "name": "channel"
190
+ },
191
+ {
192
+ "id": 30,
193
+ "methods": [{"id": 10,
194
+ "arguments": [{"type": "shortstr", "name": "realm"},
195
+ {"type": "bit", "name": "exclusive"},
196
+ {"type": "bit", "name": "passive"},
197
+ {"type": "bit", "name": "active"},
198
+ {"type": "bit", "name": "write"},
199
+ {"type": "bit", "name": "read"}],
200
+ "name": "request"},
201
+ {"id": 11,
202
+ "arguments": [{"type": "short", "name": "ticket"}],
203
+ "name": "request-ok"}],
204
+ "name": "access"
205
+ },
206
+ {
207
+ "id": 40,
208
+ "methods": [{"id": 10,
209
+ "arguments": [{"type": "short", "name": "ticket"},
210
+ {"type": "shortstr", "name": "exchange"},
211
+ {"type": "shortstr", "name": "type"},
212
+ {"type": "bit", "name": "passive"},
213
+ {"type": "bit", "name": "durable"},
214
+ {"type": "bit", "name": "auto-delete"},
215
+ {"type": "bit", "name": "internal"},
216
+ {"type": "bit", "name": "nowait"},
217
+ {"type": "table", "name": "arguments"}],
218
+ "name": "declare"},
219
+ {"id": 11,
220
+ "arguments": [],
221
+ "name": "declare-ok"},
222
+ {"id": 20,
223
+ "arguments": [{"type": "short", "name": "ticket"},
224
+ {"type": "shortstr", "name": "exchange"},
225
+ {"type": "bit", "name": "if-unused"},
226
+ {"type": "bit", "name": "nowait"}],
227
+ "name": "delete"},
228
+ {"id": 21,
229
+ "arguments": [],
230
+ "name": "delete-ok"}],
231
+ "name": "exchange"
232
+ },
233
+ {
234
+ "id": 50,
235
+ "methods": [{"id": 10,
236
+ "arguments": [{"type": "short", "name": "ticket"},
237
+ {"type": "shortstr", "name": "queue"},
238
+ {"type": "bit", "name": "passive"},
239
+ {"type": "bit", "name": "durable"},
240
+ {"type": "bit", "name": "exclusive"},
241
+ {"type": "bit", "name": "auto-delete"},
242
+ {"type": "bit", "name": "nowait"},
243
+ {"type": "table", "name": "arguments"}],
244
+ "name": "declare"},
245
+ {"id": 11,
246
+ "arguments": [{"type": "shortstr", "name": "queue"},
247
+ {"type": "long", "name": "message-count"},
248
+ {"type": "long", "name": "consumer-count"}],
249
+ "name": "declare-ok"},
250
+ {"id": 20,
251
+ "arguments": [{"type": "short", "name": "ticket"},
252
+ {"type": "shortstr", "name": "queue"},
253
+ {"type": "shortstr", "name": "exchange"},
254
+ {"type": "shortstr", "name": "routing-key"},
255
+ {"type": "bit", "name": "nowait"},
256
+ {"type": "table", "name": "arguments"}],
257
+ "name": "bind"},
258
+ {"id": 21,
259
+ "arguments": [],
260
+ "name": "bind-ok"},
261
+ {"id": 30,
262
+ "arguments": [{"type": "short", "name": "ticket"},
263
+ {"type": "shortstr", "name": "queue"},
264
+ {"type": "bit", "name": "nowait"}],
265
+ "name": "purge"},
266
+ {"id": 31,
267
+ "arguments": [{"type": "long", "name": "message-count"}],
268
+ "name": "purge-ok"},
269
+ {"id": 40,
270
+ "arguments": [{"type": "short", "name": "ticket"},
271
+ {"type": "shortstr", "name": "queue"},
272
+ {"type": "bit", "name": "if-unused"},
273
+ {"type": "bit", "name": "if-empty"},
274
+ {"type": "bit", "name": "nowait"}],
275
+ "name": "delete"},
276
+ {"id": 41,
277
+ "arguments": [{"type": "long", "name": "message-count"}],
278
+ "name": "delete-ok"}],
279
+ "name": "queue"
280
+ },
281
+ {
282
+ "id": 60,
283
+ "methods": [{"id": 10,
284
+ "arguments": [{"type": "long", "name": "prefetch-size"},
285
+ {"type": "short", "name": "prefetch-count"},
286
+ {"type": "bit", "name": "global"}],
287
+ "name": "qos"},
288
+ {"id": 11,
289
+ "arguments": [],
290
+ "name": "qos-ok"},
291
+ {"id": 20,
292
+ "arguments": [{"domain": "access-ticket", "name": "ticket"},
293
+ {"domain": "queue-name", "name": "queue"},
294
+ {"type": "shortstr", "name": "consumer-tag"},
295
+ {"type": "bit", "name": "no-local"},
296
+ {"type": "bit", "name": "no-ack"},
297
+ {"type": "bit", "name": "exclusive"},
298
+ {"type": "bit", "name": "nowait"}],
299
+ "name": "consume"},
300
+ {"id": 21,
301
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"}],
302
+ "name": "consume-ok"},
303
+ {"id": 30,
304
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"},
305
+ {"type": "bit", "name": "nowait"}],
306
+ "name": "cancel"},
307
+ {"id": 31,
308
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"}],
309
+ "name": "cancel-ok"},
310
+ {"content": true,
311
+ "id": 40,
312
+ "arguments": [{"type": "short", "name": "ticket"},
313
+ {"type": "shortstr", "name": "exchange"},
314
+ {"type": "shortstr", "name": "routing-key"},
315
+ {"type": "bit", "name": "mandatory"},
316
+ {"type": "bit", "name": "immediate"}],
317
+ "name": "publish"},
318
+ {"content": true,
319
+ "id": 50,
320
+ "arguments": [{"type": "short", "name": "reply-code"},
321
+ {"type": "shortstr", "name": "reply-text"},
322
+ {"type": "shortstr", "name": "exchange"},
323
+ {"type": "shortstr", "name": "routing-key"}],
324
+ "name": "return"},
325
+ {"content": true,
326
+ "id": 60,
327
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"},
328
+ {"type": "longlong", "name": "delivery-tag"},
329
+ {"type": "bit", "name": "redelivered"},
330
+ {"type": "shortstr", "name": "exchange"},
331
+ {"type": "shortstr", "name": "routing-key"}],
332
+ "name": "deliver"},
333
+ {"id": 70,
334
+ "arguments": [{"type": "short", "name": "ticket"},
335
+ {"type": "shortstr", "name": "queue"},
336
+ {"type": "bit", "name": "no-ack"}],
337
+ "name": "get"},
338
+ {"content": true,
339
+ "id": 71,
340
+ "arguments": [{"type": "longlong", "name": "delivery-tag"},
341
+ {"type": "bit", "name": "redelivered"},
342
+ {"type": "shortstr", "name": "exchange"},
343
+ {"type": "shortstr", "name": "routing-key"},
344
+ {"type": "long", "name": "message-count"}],
345
+ "name": "get-ok"},
346
+ {"id": 72,
347
+ "arguments": [{"type": "shortstr", "name": "cluster-id"}],
348
+ "name": "get-empty"},
349
+ {"id": 80,
350
+ "arguments": [{"type": "longlong", "name": "delivery-tag"},
351
+ {"type": "bit", "name": "multiple"}],
352
+ "name": "ack"},
353
+ {"id": 90,
354
+ "arguments": [{"type": "longlong", "name": "delivery-tag"},
355
+ {"type": "bit", "name": "requeue"}],
356
+ "name": "reject"},
357
+ {"id": 100,
358
+ "arguments": [{"type": "bit", "name": "requeue"}],
359
+ "name": "recover"}],
360
+ "name": "basic",
361
+ "properties": [{"type": "shortstr", "name": "content-type"},
362
+ {"type": "shortstr", "name": "content-encoding"},
363
+ {"type": "table", "name": "headers"},
364
+ {"type": "octet", "name": "delivery-mode"},
365
+ {"type": "octet", "name": "priority"},
366
+ {"type": "shortstr", "name": "correlation-id"},
367
+ {"type": "shortstr", "name": "reply-to"},
368
+ {"type": "shortstr", "name": "expiration"},
369
+ {"type": "shortstr", "name": "message-id"},
370
+ {"type": "timestamp", "name": "timestamp"},
371
+ {"type": "shortstr", "name": "type"},
372
+ {"type": "shortstr", "name": "user-id"},
373
+ {"type": "shortstr", "name": "app-id"},
374
+ {"type": "shortstr", "name": "cluster-id"}]
375
+ },
376
+ {
377
+ "id": 70,
378
+ "methods": [{"id": 10,
379
+ "arguments": [{"type": "long", "name": "prefetch-size"},
380
+ {"type": "short", "name": "prefetch-count"},
381
+ {"type": "bit", "name": "global"}],
382
+ "name": "qos"},
383
+ {"id": 11,
384
+ "arguments": [],
385
+ "name": "qos-ok"},
386
+ {"id": 20,
387
+ "arguments": [{"type": "short", "name": "ticket"},
388
+ {"type": "shortstr", "name": "queue"},
389
+ {"type": "shortstr", "name": "consumer-tag"},
390
+ {"type": "bit", "name": "no-local"},
391
+ {"type": "bit", "name": "no-ack"},
392
+ {"type": "bit", "name": "exclusive"},
393
+ {"type": "bit", "name": "nowait"}],
394
+ "name": "consume"},
395
+ {"id": 21,
396
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"}],
397
+ "name": "consume-ok"},
398
+ {"id": 30,
399
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"},
400
+ {"type": "bit", "name": "nowait"}],
401
+ "name": "cancel"},
402
+ {"id": 31,
403
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"}],
404
+ "name": "cancel-ok"},
405
+ {"id": 40,
406
+ "arguments": [{"type": "shortstr", "name": "identifier"},
407
+ {"type": "longlong", "name": "content-size"}],
408
+ "name": "open"},
409
+ {"id": 41,
410
+ "arguments": [{"type": "longlong", "name": "staged-size"}],
411
+ "name": "open-ok"},
412
+ {"content": true,
413
+ "id": 50,
414
+ "arguments": [],
415
+ "name": "stage"},
416
+ {"id": 60,
417
+ "arguments": [{"type": "short", "name": "ticket"},
418
+ {"type": "shortstr", "name": "exchange"},
419
+ {"type": "shortstr", "name": "routing-key"},
420
+ {"type": "bit", "name": "mandatory"},
421
+ {"type": "bit", "name": "immediate"},
422
+ {"type": "shortstr", "name": "identifier"}],
423
+ "name": "publish"},
424
+ {"content": true,
425
+ "id": 70,
426
+ "arguments": [{"type": "short", "name": "reply-code"},
427
+ {"type": "shortstr", "name": "reply-text"},
428
+ {"type": "shortstr", "name": "exchange"},
429
+ {"type": "shortstr", "name": "routing-key"}],
430
+ "name": "return"},
431
+ {"id": 80,
432
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"},
433
+ {"type": "longlong", "name": "delivery-tag"},
434
+ {"type": "bit", "name": "redelivered"},
435
+ {"type": "shortstr", "name": "exchange"},
436
+ {"type": "shortstr", "name": "routing-key"},
437
+ {"type": "shortstr", "name": "identifier"}],
438
+ "name": "deliver"},
439
+ {"id": 90,
440
+ "arguments": [{"type": "longlong", "name": "delivery-tag"},
441
+ {"type": "bit", "name": "multiple"}],
442
+ "name": "ack"},
443
+ {"id": 100,
444
+ "arguments": [{"type": "longlong", "name": "delivery-tag"},
445
+ {"type": "bit", "name": "requeue"}],
446
+ "name": "reject"}],
447
+ "name": "file",
448
+ "properties": [{"type": "shortstr", "name": "content-type"},
449
+ {"type": "shortstr", "name": "content-encoding"},
450
+ {"type": "table", "name": "headers"},
451
+ {"type": "octet", "name": "priority"},
452
+ {"type": "shortstr", "name": "reply-to"},
453
+ {"type": "shortstr", "name": "message-id"},
454
+ {"type": "shortstr", "name": "filename"},
455
+ {"type": "timestamp", "name": "timestamp"},
456
+ {"type": "shortstr", "name": "cluster-id"}]
457
+ },
458
+ {
459
+ "id": 80,
460
+ "methods": [{"id": 10,
461
+ "arguments": [{"type": "long", "name": "prefetch-size"},
462
+ {"type": "short", "name": "prefetch-count"},
463
+ {"type": "long", "name": "consume-rate"},
464
+ {"type": "bit", "name": "global"}],
465
+ "name": "qos"},
466
+ {"id": 11,
467
+ "arguments": [],
468
+ "name": "qos-ok"},
469
+ {"id": 20,
470
+ "arguments": [{"type": "short", "name": "ticket"},
471
+ {"type": "shortstr", "name": "queue"},
472
+ {"type": "shortstr", "name": "consumer-tag"},
473
+ {"type": "bit", "name": "no-local"},
474
+ {"type": "bit", "name": "exclusive"},
475
+ {"type": "bit", "name": "nowait"}],
476
+ "name": "consume"},
477
+ {"id": 21,
478
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"}],
479
+ "name": "consume-ok"},
480
+ {"id": 30,
481
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"},
482
+ {"type": "bit", "name": "nowait"}],
483
+ "name": "cancel"},
484
+ {"id": 31,
485
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"}],
486
+ "name": "cancel-ok"},
487
+ {"content": true,
488
+ "id": 40,
489
+ "arguments": [{"type": "short", "name": "ticket"},
490
+ {"type": "shortstr", "name": "exchange"},
491
+ {"type": "shortstr", "name": "routing-key"},
492
+ {"type": "bit", "name": "mandatory"},
493
+ {"type": "bit", "name": "immediate"}],
494
+ "name": "publish"},
495
+ {"content": true,
496
+ "id": 50,
497
+ "arguments": [{"type": "short", "name": "reply-code"},
498
+ {"type": "shortstr", "name": "reply-text"},
499
+ {"type": "shortstr", "name": "exchange"},
500
+ {"type": "shortstr", "name": "routing-key"}],
501
+ "name": "return"},
502
+ {"content": true,
503
+ "id": 60,
504
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"},
505
+ {"type": "longlong", "name": "delivery-tag"},
506
+ {"type": "shortstr", "name": "exchange"},
507
+ {"type": "shortstr", "name": "queue"}],
508
+ "name": "deliver"}],
509
+ "name": "stream",
510
+ "properties": [{"type": "shortstr", "name": "content-type"},
511
+ {"type": "shortstr", "name": "content-encoding"},
512
+ {"type": "table", "name": "headers"},
513
+ {"type": "octet", "name": "priority"},
514
+ {"type": "timestamp", "name": "timestamp"}]
515
+ },
516
+ {
517
+ "id": 90,
518
+ "methods": [{"id": 10,
519
+ "arguments": [],
520
+ "name": "select"},
521
+ {"id": 11,
522
+ "arguments": [],
523
+ "name": "select-ok"},
524
+ {"id": 20,
525
+ "arguments": [],
526
+ "name": "commit"},
527
+ {"id": 21,
528
+ "arguments": [],
529
+ "name": "commit-ok"},
530
+ {"id": 30,
531
+ "arguments": [],
532
+ "name": "rollback"},
533
+ {"id": 31,
534
+ "arguments": [],
535
+ "name": "rollback-ok"}],
536
+ "name": "tx"
537
+ },
538
+ {
539
+ "id": 100,
540
+ "methods": [{"id": 10,
541
+ "arguments": [],
542
+ "name": "select"},
543
+ {"id": 11,
544
+ "arguments": [],
545
+ "name": "select-ok"},
546
+ {"id": 20,
547
+ "arguments": [{"type": "shortstr", "name": "dtx-identifier"}],
548
+ "name": "start"},
549
+ {"id": 21,
550
+ "arguments": [], "name": "start-ok"}],
551
+ "name": "dtx"
552
+ },
553
+ {
554
+ "id": 110,
555
+ "methods": [{"content": true,
556
+ "id": 10,
557
+ "arguments": [{"type": "table", "name": "meta-data"}],
558
+ "name": "request"}],
559
+ "name": "tunnel",
560
+ "properties": [{"type": "table", "name": "headers"},
561
+ {"type": "shortstr", "name": "proxy-name"},
562
+ {"type": "shortstr", "name": "data-name"},
563
+ {"type": "octet", "name": "durable"},
564
+ {"type": "octet", "name": "broadcast"}]
565
+ },
566
+ {
567
+ "id": 120,
568
+ "methods": [{"id": 10,
569
+ "arguments": [{"type": "octet", "name": "integer-1"},
570
+ {"type": "short", "name": "integer-2"},
571
+ {"type": "long", "name": "integer-3"},
572
+ {"type": "longlong", "name": "integer-4"},
573
+ {"type": "octet", "name": "operation"}],
574
+ "name": "integer"},
575
+ {"id": 11,
576
+ "arguments": [{"type": "longlong", "name": "result"}],
577
+ "name": "integer-ok"},
578
+ {"id": 20,
579
+ "arguments": [{"type": "shortstr", "name": "string-1"},
580
+ {"type": "longstr", "name": "string-2"},
581
+ {"type": "octet", "name": "operation"}],
582
+ "name": "string"},
583
+ {"id": 21,
584
+ "arguments": [{"type": "longstr", "name": "result"}],
585
+ "name": "string-ok"},
586
+ {"id": 30,
587
+ "arguments": [{"type": "table", "name": "table"},
588
+ {"type": "octet", "name": "integer-op"},
589
+ {"type": "octet", "name": "string-op"}],
590
+ "name": "table"},
591
+ {"id": 31,
592
+ "arguments": [{"type": "longlong", "name": "integer-result"},
593
+ {"type": "longstr", "name": "string-result"}],
594
+ "name": "table-ok"},
595
+ {"content": true,
596
+ "id": 40,
597
+ "arguments": [],
598
+ "name": "content"},
599
+ {"content": true,
600
+ "id": 41,
601
+ "arguments": [{"type": "long", "name": "content-checksum"}],
602
+ "name": "content-ok"}],
603
+ "name": "test"
604
+ }
605
+ ]
606
+ }