amqp 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,229 @@
1
+ $:.unshift File.expand_path(File.dirname(File.expand_path(__FILE__)))
2
+ require 'amqp'
3
+
4
+ unless defined?(BlankSlate)
5
+ class BlankSlate < BasicObject; end if defined?(BasicObject)
6
+
7
+ class BlankSlate
8
+ instance_methods.each { |m| undef_method m unless m =~ /^__/ }
9
+ end
10
+ end
11
+
12
+ class MQ
13
+ include AMQP
14
+ include EM::Deferrable
15
+
16
+ class Exchange
17
+ include AMQP
18
+
19
+ def initialize mq, type, name, opts = {}
20
+ if name.is_a? Hash
21
+ opts = name
22
+ name = "amq.#{type}"
23
+ end
24
+
25
+ @mq = mq
26
+ @type, @name = type, name
27
+ @key = opts[:key]
28
+
29
+ @mq.callback{
30
+ @mq.send Protocol::Exchange::Declare.new({ :exchange => name,
31
+ :type => type,
32
+ :nowait => true }.merge(opts))
33
+ } unless name == "amq.#{type}"
34
+ end
35
+ attr_reader :name, :type, :key
36
+
37
+ def publish data, opts = {}
38
+ @mq.callback{
39
+ @mq.send Protocol::Basic::Publish.new({ :exchange => name,
40
+ :routing_key => opts.delete(:key) || @key }.merge(opts))
41
+
42
+ data = data.to_s
43
+
44
+ @mq.send Protocol::Header.new(Protocol::Basic,
45
+ data.length, { :content_type => 'application/octet-stream',
46
+ :delivery_mode => 1,
47
+ :priority => 0 }.merge(opts))
48
+ @mq.send Frame::Body.new(data)
49
+ }
50
+ self
51
+ end
52
+ end
53
+
54
+ class Queue
55
+ include AMQP
56
+
57
+ def initialize mq, name, opts = {}
58
+ @mq = mq
59
+ @name = name
60
+ @mq.callback{
61
+ @mq.send Protocol::Queue::Declare.new({ :queue => name,
62
+ :nowait => true }.merge(opts))
63
+ }
64
+ bind(@mq.direct, :key => name)
65
+ end
66
+ attr_reader :name
67
+
68
+ def bind exchange, opts = {}
69
+ @mq.callback{
70
+ @mq.send Protocol::Queue::Bind.new({ :queue => name,
71
+ :exchange => exchange.respond_to?(:name) ? exchange.name : exchange,
72
+ :routing_key => opts.delete(:key),
73
+ :nowait => true }.merge(opts))
74
+ }
75
+ self
76
+ end
77
+
78
+ def subscribe opts = {}, &blk
79
+ @on_msg = blk
80
+ @mq.callback{
81
+ @mq.send Protocol::Basic::Consume.new({ :queue => name,
82
+ :consumer_tag => name,
83
+ :no_ack => true,
84
+ :nowait => true }.merge(opts))
85
+ }
86
+ self
87
+ end
88
+
89
+ def receive headers, body
90
+ if @on_msg
91
+ @on_msg.call *(@on_msg.arity == 1 ? [body] : [headers, body])
92
+ end
93
+ end
94
+ end
95
+
96
+ class RPC < BlankSlate
97
+ def initialize mq, queue, obj = nil
98
+ @mq = mq
99
+
100
+ if obj
101
+ @obj = case obj
102
+ when Class
103
+ obj.new
104
+ when Module
105
+ (::Class.new do include(obj) end).new
106
+ else
107
+ obj
108
+ end
109
+
110
+ @mq.queue(queue).subscribe{ |info, request|
111
+ method, *args = Marshal.load(request)
112
+ ret = @obj.__send__(method, *args)
113
+
114
+ if info.reply_to
115
+ @mq.direct.publish(Marshal.dump(ret), :key => info.reply_to, :message_id => info.message_id)
116
+ end
117
+ }
118
+ else
119
+ @callbacks ||= {}
120
+ @queue = @mq.queue(@name = 'some random identifier for me').subscribe{|info, msg|
121
+ ret = Marshal.load(msg)
122
+ if blk = @callbacks.delete(info.message_id)
123
+ blk.call(ret)
124
+ end
125
+ }
126
+ @exchange = @mq.direct(:key => queue)
127
+ end
128
+ end
129
+
130
+ def method_missing meth, *args, &blk
131
+ message_id = "random message id #{rand(999_999_999_999)}"
132
+ @callbacks[message_id] = blk if blk
133
+ @exchange.publish(Marshal.dump([meth, *args]), :reply_to => blk ? @name : nil, :message_id => message_id)
134
+ end
135
+ end
136
+ end
137
+
138
+ class MQ
139
+ def initialize
140
+ conn.callback{ |c|
141
+ @channel = c.add_channel(self)
142
+ send Protocol::Channel::Open.new
143
+ }
144
+ end
145
+ attr_reader :channel
146
+
147
+ def process_frame frame
148
+ case frame
149
+ when Frame::Header
150
+ @header = frame.payload
151
+ @body = ''
152
+
153
+ when Frame::Body
154
+ @body << frame.payload
155
+ if @body.length >= @header.size
156
+ @consumer.receive @header, @body
157
+ @body = ''
158
+ end
159
+
160
+ when Frame::Method
161
+ case method = frame.payload
162
+ when Protocol::Channel::OpenOk
163
+ send Protocol::Access::Request.new(:realm => '/data',
164
+ :read => true,
165
+ :write => true,
166
+ :active => true)
167
+
168
+ when Protocol::Access::RequestOk
169
+ @ticket = method.ticket
170
+ succeed
171
+
172
+ when Protocol::Basic::Deliver
173
+ @header = nil
174
+ @body = ''
175
+ @consumer = queues[ method.consumer_tag ]
176
+ end
177
+ end
178
+ end
179
+
180
+ def send data
181
+ data.ticket = @ticket if @ticket and data.respond_to? :ticket
182
+ conn.callback{ |c|
183
+ c.send data, :channel => @channel
184
+ }
185
+ end
186
+
187
+ %w[ direct topic fanout ].each do |type|
188
+ class_eval %[
189
+ def #{type} name = 'amq.#{type}', opts = {}
190
+ exchanges[name] ||= Exchange.new(self, :#{type}, name, opts)
191
+ end
192
+ ]
193
+ end
194
+
195
+ def queue name, opts = {}
196
+ queues[name] ||= Queue.new(self, name, opts)
197
+ end
198
+
199
+ def rpc name, obj = nil
200
+ rpcs[name] ||= RPC.new(self, name, obj)
201
+ end
202
+
203
+ private
204
+
205
+ def exchanges
206
+ @exchanges ||= {}
207
+ end
208
+
209
+ def queues
210
+ @queues ||= {}
211
+ end
212
+
213
+ def rpcs
214
+ @rcps ||= {}
215
+ end
216
+
217
+ def connection
218
+ @@connection ||= AMQP.start
219
+ end
220
+ alias :conn :connection
221
+
222
+ def MQ.method_missing meth, *args, &blk
223
+ MQ.default.__send__(meth, *args, &blk)
224
+ end
225
+
226
+ def MQ.default
227
+ Thread.current[:mq] ||= MQ.new
228
+ end
229
+ 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
+ }