amqplib 0.10.3 → 0.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +7 -4
  2. package/.github/workflows/publish.yml +59 -0
  3. package/.github/workflows/test.yml +15 -2
  4. package/CHANGELOG.md +14 -1
  5. package/Makefile +22 -20
  6. package/README.md +1 -2
  7. package/bin/amqp-rabbitmq-0.9.1.json +483 -0
  8. package/bin/generate-defs.js +5 -5
  9. package/examples/direct_reply_to_client.js +22 -0
  10. package/examples/direct_reply_to_server.js +25 -0
  11. package/examples/headers.js +29 -31
  12. package/examples/ssl.js +16 -10
  13. package/examples/stream_queues/README.md +40 -0
  14. package/examples/stream_queues/package.json +14 -0
  15. package/examples/stream_queues/receive_stream.js +55 -0
  16. package/examples/stream_queues/send_stream.js +38 -0
  17. package/examples/tutorials/callback_api/emit_log.js +22 -22
  18. package/examples/tutorials/callback_api/emit_log_direct.js +24 -24
  19. package/examples/tutorials/callback_api/emit_log_topic.js +23 -20
  20. package/examples/tutorials/callback_api/new_task.js +21 -20
  21. package/examples/tutorials/callback_api/receive.js +27 -21
  22. package/examples/tutorials/callback_api/receive_logs.js +32 -26
  23. package/examples/tutorials/callback_api/receive_logs_direct.js +42 -41
  24. package/examples/tutorials/callback_api/receive_logs_topic.js +43 -40
  25. package/examples/tutorials/callback_api/rpc_client.js +39 -37
  26. package/examples/tutorials/callback_api/rpc_server.js +42 -32
  27. package/examples/tutorials/callback_api/send.js +21 -22
  28. package/examples/tutorials/callback_api/worker.js +29 -25
  29. package/examples/tutorials/emit_log.js +20 -15
  30. package/examples/tutorials/emit_log_direct.js +22 -16
  31. package/examples/tutorials/emit_log_topic.js +22 -15
  32. package/examples/tutorials/new_task.js +20 -13
  33. package/examples/tutorials/receive.js +19 -14
  34. package/examples/tutorials/receive_logs.js +25 -23
  35. package/examples/tutorials/receive_logs_direct.js +29 -35
  36. package/examples/tutorials/receive_logs_topic.js +28 -32
  37. package/examples/tutorials/rpc_client.js +37 -40
  38. package/examples/tutorials/rpc_server.js +36 -29
  39. package/examples/tutorials/send.js +26 -18
  40. package/examples/tutorials/worker.js +27 -21
  41. package/examples/waitForConfirms.js +18 -19
  42. package/lib/callback_model.js +295 -290
  43. package/lib/channel.js +353 -346
  44. package/lib/channel_model.js +5 -1
  45. package/lib/codec.js +26 -2
  46. package/lib/connection.js +544 -532
  47. package/lib/credentials.js +1 -1
  48. package/lib/defs.js +2568 -2457
  49. package/lib/format.js +0 -1
  50. package/lib/heartbeat.js +32 -29
  51. package/lib/mux.js +96 -99
  52. package/package.json +3 -5
  53. package/test/callback_api.js +182 -174
  54. package/test/channel_api.js +455 -445
  55. package/test/codec.js +15 -15
  56. package/test/data.js +15 -0
  57. package/test/frame.js +6 -7
  58. package/test/mux.js +1 -2
  59. package/test/util.js +1 -3
@@ -0,0 +1,483 @@
1
+ {
2
+ "name": "AMQP",
3
+ "major-version": 0,
4
+ "minor-version": 9,
5
+ "revision": 1,
6
+ "port": 5672,
7
+ "copyright": [
8
+ "Copyright (C) 2008-2020 VMware, Inc. or its affiliates.\n",
9
+ "\n",
10
+ "Permission is hereby granted, free of charge, to any person\n",
11
+ "obtaining a copy of this file (the \"Software\"), to deal in the\n",
12
+ "Software without restriction, including without limitation the \n",
13
+ "rights to use, copy, modify, merge, publish, distribute, \n",
14
+ "sublicense, and/or sell copies of the Software, and to permit \n",
15
+ "persons to whom the Software is furnished to do so, subject to \n",
16
+ "the following conditions:\n",
17
+ "\n",
18
+ "The above copyright notice and this permission notice shall be\n",
19
+ "included in all copies or substantial portions of the Software.\n",
20
+ "\n",
21
+ "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n",
22
+ "EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n",
23
+ "OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n",
24
+ "NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n",
25
+ "HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n",
26
+ "WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n",
27
+ "FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n",
28
+ "OTHER DEALINGS IN THE SOFTWARE.\n",
29
+ "\n",
30
+ "Class information entered from amqp_xml0-8.pdf and domain types from amqp-xml-doc0-9.pdf\n",
31
+ "Updated for 0-9-1 by Tony Garnock-Jones\n",
32
+ "\n",
33
+ "b3cb053f15e7b98808c0ccc67f23cb3e amqp_xml0-8.pdf\n",
34
+ "http://twiststandards.org/?option=com_docman&task=cat_view&gid=28&Itemid=90\n",
35
+ "8444db91e2949dbecfb2585e9eef6d64 amqp-xml-doc0-9.pdf\n",
36
+ "https://jira.amqp.org/confluence/download/attachments/720900/amqp-xml-doc0-9.pdf?version=1\n"],
37
+
38
+ "domains": [
39
+ ["bit", "bit"],
40
+ ["channel-id", "longstr"],
41
+ ["class-id", "short"],
42
+ ["consumer-tag", "shortstr"],
43
+ ["delivery-tag", "longlong"],
44
+ ["destination", "shortstr"],
45
+ ["duration", "longlong"],
46
+ ["exchange-name", "shortstr"],
47
+ ["long", "long"],
48
+ ["longlong", "longlong"],
49
+ ["longstr", "longstr"],
50
+ ["message-count", "long"],
51
+ ["method-id", "short"],
52
+ ["no-ack", "bit"],
53
+ ["no-local", "bit"],
54
+ ["octet", "octet"],
55
+ ["offset", "longlong"],
56
+ ["path", "shortstr"],
57
+ ["peer-properties", "table"],
58
+ ["queue-name", "shortstr"],
59
+ ["redelivered", "bit"],
60
+ ["reference", "longstr"],
61
+ ["reject-code", "short"],
62
+ ["reject-text", "shortstr"],
63
+ ["reply-code", "short"],
64
+ ["reply-text", "shortstr"],
65
+ ["security-token", "longstr"],
66
+ ["short", "short"],
67
+ ["shortstr", "shortstr"],
68
+ ["table", "table"],
69
+ ["timestamp", "timestamp"]
70
+ ],
71
+
72
+ "constants": [
73
+ {"name": "FRAME-METHOD", "value": 1},
74
+ {"name": "FRAME-HEADER", "value": 2},
75
+ {"name": "FRAME-BODY", "value": 3},
76
+ {"name": "FRAME-HEARTBEAT", "value": 8},
77
+ {"name": "FRAME-MIN-SIZE", "value": 4096},
78
+ {"name": "FRAME-END", "value": 206},
79
+ {"name": "REPLY-SUCCESS", "value": 200},
80
+ {"name": "CONTENT-TOO-LARGE", "value": 311, "class": "soft-error"},
81
+ {"name": "NO-ROUTE", "value": 312, "class": "soft-error"},
82
+ {"name": "NO-CONSUMERS", "value": 313, "class": "soft-error"},
83
+ {"name": "ACCESS-REFUSED", "value": 403, "class": "soft-error"},
84
+ {"name": "NOT-FOUND", "value": 404, "class": "soft-error"},
85
+ {"name": "RESOURCE-LOCKED", "value": 405, "class": "soft-error"},
86
+ {"name": "PRECONDITION-FAILED", "value": 406, "class": "soft-error"},
87
+ {"name": "CONNECTION-FORCED", "value": 320, "class": "hard-error"},
88
+ {"name": "INVALID-PATH", "value": 402, "class": "hard-error"},
89
+ {"name": "FRAME-ERROR", "value": 501, "class": "hard-error"},
90
+ {"name": "SYNTAX-ERROR", "value": 502, "class": "hard-error"},
91
+ {"name": "COMMAND-INVALID", "value": 503, "class": "hard-error"},
92
+ {"name": "CHANNEL-ERROR", "value": 504, "class": "hard-error"},
93
+ {"name": "UNEXPECTED-FRAME", "value": 505, "class": "hard-error"},
94
+ {"name": "RESOURCE-ERROR", "value": 506, "class": "hard-error"},
95
+ {"name": "NOT-ALLOWED", "value": 530, "class": "hard-error"},
96
+ {"name": "NOT-IMPLEMENTED", "value": 540, "class": "hard-error"},
97
+ {"name": "INTERNAL-ERROR", "value": 541, "class": "hard-error"}
98
+ ],
99
+
100
+ "classes": [
101
+ {
102
+ "id": 60,
103
+ "methods": [{"id": 10,
104
+ "arguments": [{"type": "long", "name": "prefetch-size", "default-value": 0},
105
+ {"type": "short", "name": "prefetch-count", "default-value": 0},
106
+ {"type": "bit", "name": "global", "default-value": false}],
107
+ "name": "qos",
108
+ "synchronous" : true},
109
+ {"id": 11,
110
+ "arguments": [],
111
+ "name": "qos-ok"},
112
+ {"id": 20,
113
+ "arguments": [{"domain": "short", "name": "ticket", "default-value": 0},
114
+ {"domain": "queue-name", "name": "queue", "default-value": ""},
115
+ {"type": "shortstr", "name": "consumer-tag", "default-value": ""},
116
+ {"type": "bit", "name": "no-local", "default-value": false},
117
+ {"type": "bit", "name": "no-ack", "default-value": false},
118
+ {"type": "bit", "name": "exclusive", "default-value": false},
119
+ {"type": "bit", "name": "nowait", "default-value": false},
120
+ {"type": "table", "name": "arguments", "default-value": {}}],
121
+ "name": "consume",
122
+ "synchronous" : true},
123
+ {"id": 21,
124
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"}],
125
+ "name": "consume-ok"},
126
+ {"id": 30,
127
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"},
128
+ {"type": "bit", "name": "nowait", "default-value": false}],
129
+ "name": "cancel",
130
+ "synchronous" : true},
131
+ {"id": 31,
132
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"}],
133
+ "name": "cancel-ok"},
134
+ {"content": true,
135
+ "id": 40,
136
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
137
+ {"domain": "exchange-name", "name": "exchange", "default-value": ""},
138
+ {"type": "shortstr", "name": "routing-key", "default-value": ""},
139
+ {"type": "bit", "name": "mandatory", "default-value": false},
140
+ {"type": "bit", "name": "immediate", "default-value": false}],
141
+ "name": "publish"},
142
+ {"content": true,
143
+ "id": 50,
144
+ "arguments": [{"type": "short", "name": "reply-code"},
145
+ {"type": "shortstr", "name": "reply-text", "default-value": ""},
146
+ {"domain": "exchange-name", "name": "exchange"},
147
+ {"type": "shortstr", "name": "routing-key"}],
148
+ "name": "return"},
149
+ {"content": true,
150
+ "id": 60,
151
+ "arguments": [{"type": "shortstr", "name": "consumer-tag"},
152
+ {"type": "longlong", "name": "delivery-tag"},
153
+ {"type": "bit", "name": "redelivered", "default-value": false},
154
+ {"domain": "exchange-name", "name": "exchange"},
155
+ {"type": "shortstr", "name": "routing-key"}],
156
+ "name": "deliver"},
157
+ {"id": 70,
158
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
159
+ {"domain": "queue-name", "name": "queue", "default-value": ""},
160
+ {"type": "bit", "name": "no-ack", "default-value": false}],
161
+ "name": "get",
162
+ "synchronous" : true},
163
+ {"content": true,
164
+ "id": 71,
165
+ "arguments": [{"type": "longlong", "name": "delivery-tag"},
166
+ {"type": "bit", "name": "redelivered", "default-value": false},
167
+ {"domain": "exchange-name", "name": "exchange"},
168
+ {"type": "shortstr", "name": "routing-key"},
169
+ {"domain": "message-count", "name": "message-count"}],
170
+ "name": "get-ok"},
171
+ {"id": 72,
172
+ "arguments": [{"type": "shortstr", "name": "cluster-id", "default-value": ""}],
173
+ "name": "get-empty"},
174
+ {"id": 80,
175
+ "arguments": [{"type": "longlong", "name": "delivery-tag", "default-value": 0},
176
+ {"type": "bit", "name": "multiple", "default-value": false}],
177
+ "name": "ack"},
178
+ {"id": 90,
179
+ "arguments": [{"type": "longlong", "name": "delivery-tag"},
180
+ {"type": "bit", "name": "requeue", "default-value": true}],
181
+ "name": "reject"},
182
+ {"id": 100,
183
+ "arguments": [{"type": "bit", "name": "requeue", "default-value": false}],
184
+ "name": "recover-async"},
185
+ {"id": 110,
186
+ "arguments": [{"type": "bit", "name": "requeue", "default-value": false}],
187
+ "name": "recover",
188
+ "synchronous" : true},
189
+ {"id": 111,
190
+ "arguments": [],
191
+ "name": "recover-ok"},
192
+ {"id": 120,
193
+ "arguments": [{"type": "longlong", "name": "delivery-tag", "default-value": 0},
194
+ {"type": "bit", "name": "multiple", "default-value": false},
195
+ {"type": "bit", "name": "requeue", "default-value": true}],
196
+ "name": "nack"}],
197
+ "name": "basic",
198
+ "properties": [{"type": "shortstr", "name": "content-type"},
199
+ {"type": "shortstr", "name": "content-encoding"},
200
+ {"type": "table", "name": "headers"},
201
+ {"type": "octet", "name": "delivery-mode"},
202
+ {"type": "octet", "name": "priority"},
203
+ {"type": "shortstr", "name": "correlation-id"},
204
+ {"type": "shortstr", "name": "reply-to"},
205
+ {"type": "shortstr", "name": "expiration"},
206
+ {"type": "shortstr", "name": "message-id"},
207
+ {"type": "timestamp", "name": "timestamp"},
208
+ {"type": "shortstr", "name": "type"},
209
+ {"type": "shortstr", "name": "user-id"},
210
+ {"type": "shortstr", "name": "app-id"},
211
+ {"type": "shortstr", "name": "cluster-id"}]
212
+ },
213
+ {
214
+ "id": 10,
215
+ "methods": [{"id": 10,
216
+ "arguments": [{"type": "octet", "name": "version-major", "default-value": 0},
217
+ {"type": "octet", "name": "version-minor", "default-value": 9},
218
+ {"domain": "peer-properties", "name": "server-properties"},
219
+ {"type": "longstr", "name": "mechanisms", "default-value": "PLAIN"},
220
+ {"type": "longstr", "name": "locales", "default-value": "en_US"}],
221
+ "name": "start",
222
+ "synchronous" : true},
223
+ {"id": 11,
224
+ "arguments": [{"domain": "peer-properties", "name": "client-properties"},
225
+ {"type": "shortstr", "name": "mechanism", "default-value": "PLAIN"},
226
+ {"type": "longstr", "name": "response"},
227
+ {"type": "shortstr", "name": "locale", "default-value": "en_US"}],
228
+ "name": "start-ok"},
229
+ {"id": 20,
230
+ "arguments": [{"type": "longstr", "name": "challenge"}],
231
+ "name": "secure",
232
+ "synchronous" : true},
233
+ {"id": 21,
234
+ "arguments": [{"type": "longstr", "name": "response"}],
235
+ "name": "secure-ok"},
236
+ {"id": 30,
237
+ "arguments": [{"type": "short", "name": "channel-max", "default-value": 0},
238
+ {"type": "long", "name": "frame-max", "default-value": 0},
239
+ {"type": "short", "name": "heartbeat", "default-value": 0}],
240
+ "name": "tune",
241
+ "synchronous" : true},
242
+ {"id": 31,
243
+ "arguments": [{"type": "short", "name": "channel-max", "default-value": 0},
244
+ {"type": "long", "name": "frame-max", "default-value": 0},
245
+ {"type": "short", "name": "heartbeat", "default-value": 0}],
246
+ "name": "tune-ok"},
247
+ {"id": 40,
248
+ "arguments": [{"type": "shortstr", "name": "virtual-host", "default-value": "/"},
249
+ {"type": "shortstr", "name": "capabilities", "default-value": ""},
250
+ {"type": "bit", "name": "insist", "default-value": false}],
251
+ "name": "open",
252
+ "synchronous" : true},
253
+ {"id": 41,
254
+ "arguments": [{"type": "shortstr", "name": "known-hosts", "default-value": ""}],
255
+ "name": "open-ok"},
256
+ {"id": 50,
257
+ "arguments": [{"type": "short", "name": "reply-code"},
258
+ {"type": "shortstr", "name": "reply-text", "default-value": ""},
259
+ {"type": "short", "name": "class-id"},
260
+ {"type": "short", "name": "method-id"}],
261
+ "name": "close",
262
+ "synchronous" : true},
263
+ {"id": 51,
264
+ "arguments": [],
265
+ "name": "close-ok"},
266
+ {"id": 60,
267
+ "arguments": [{"type": "shortstr", "name": "reason", "default-value": ""}],
268
+ "name": "blocked"},
269
+ {"id": 61,
270
+ "arguments": [],
271
+ "name": "unblocked"},
272
+ {"id": 70,
273
+ "arguments": [{"type": "longstr", "name": "new-secret"},
274
+ {"type": "shortstr", "name": "reason"}],
275
+ "name": "update-secret",
276
+ "synchronous" : true},
277
+ {"id": 71,
278
+ "arguments": [],
279
+ "name": "update-secret-ok"}
280
+ ],
281
+ "name": "connection",
282
+ "properties": []
283
+ },
284
+ {
285
+ "id": 20,
286
+ "methods": [{"id": 10,
287
+ "arguments": [{"type": "shortstr", "name": "out-of-band", "default-value": ""}],
288
+ "name": "open",
289
+ "synchronous" : true},
290
+ {"id": 11,
291
+ "arguments": [{"type": "longstr", "name": "channel-id", "default-value": ""}],
292
+ "name": "open-ok"},
293
+ {"id": 20,
294
+ "arguments": [{"type": "bit", "name": "active"}],
295
+ "name": "flow",
296
+ "synchronous" : true},
297
+ {"id": 21,
298
+ "arguments": [{"type": "bit", "name": "active"}],
299
+ "name": "flow-ok"},
300
+ {"id": 40,
301
+ "arguments": [{"type": "short", "name": "reply-code"},
302
+ {"type": "shortstr", "name": "reply-text", "default-value": ""},
303
+ {"type": "short", "name": "class-id"},
304
+ {"type": "short", "name": "method-id"}],
305
+ "name": "close",
306
+ "synchronous" : true},
307
+ {"id": 41,
308
+ "arguments": [],
309
+ "name": "close-ok"}],
310
+ "name": "channel"
311
+ },
312
+ {
313
+ "id": 30,
314
+ "methods": [{"id": 10,
315
+ "arguments": [{"type": "shortstr", "name": "realm", "default-value": "/data"},
316
+ {"type": "bit", "name": "exclusive", "default-value": false},
317
+ {"type": "bit", "name": "passive", "default-value": true},
318
+ {"type": "bit", "name": "active", "default-value": true},
319
+ {"type": "bit", "name": "write", "default-value": true},
320
+ {"type": "bit", "name": "read", "default-value": true}],
321
+ "name": "request",
322
+ "synchronous" : true},
323
+ {"id": 11,
324
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 1}],
325
+ "name": "request-ok"}],
326
+ "name": "access"
327
+ },
328
+ {
329
+ "id": 40,
330
+ "methods": [{"id": 10,
331
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
332
+ {"domain": "exchange-name", "name": "exchange"},
333
+ {"type": "shortstr", "name": "type", "default-value": "direct"},
334
+ {"type": "bit", "name": "passive", "default-value": false},
335
+ {"type": "bit", "name": "durable", "default-value": false},
336
+ {"type": "bit", "name": "auto-delete", "default-value": false},
337
+ {"type": "bit", "name": "internal", "default-value": false},
338
+ {"type": "bit", "name": "nowait", "default-value": false},
339
+ {"type": "table", "name": "arguments", "default-value": {}}],
340
+ "name": "declare",
341
+ "synchronous" : true},
342
+ {"id": 11,
343
+ "arguments": [],
344
+ "name": "declare-ok"},
345
+ {"id": 20,
346
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
347
+ {"domain": "exchange-name", "name": "exchange"},
348
+ {"type": "bit", "name": "if-unused", "default-value": false},
349
+ {"type": "bit", "name": "nowait", "default-value": false}],
350
+ "name": "delete",
351
+ "synchronous" : true},
352
+ {"id": 21,
353
+ "arguments": [],
354
+ "name": "delete-ok"},
355
+ {"id": 30,
356
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
357
+ {"domain": "exchange-name", "name": "destination"},
358
+ {"domain": "exchange-name", "name": "source"},
359
+ {"type": "shortstr", "name": "routing-key", "default-value": ""},
360
+ {"type": "bit", "name": "nowait", "default-value": false},
361
+ {"type": "table", "name": "arguments", "default-value": {}}],
362
+ "name": "bind",
363
+ "synchronous" : true},
364
+ {"id": 31,
365
+ "arguments": [],
366
+ "name": "bind-ok"},
367
+ {"id": 40,
368
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
369
+ {"domain": "exchange-name", "name": "destination"},
370
+ {"domain": "exchange-name", "name": "source"},
371
+ {"type": "shortstr", "name": "routing-key", "default-value": ""},
372
+ {"type": "bit", "name": "nowait", "default-value": false},
373
+ {"type": "table", "name": "arguments", "default-value": {}}],
374
+ "name": "unbind",
375
+ "synchronous" : true},
376
+ {"id": 51,
377
+ "arguments": [],
378
+ "name": "unbind-ok"}],
379
+ "name": "exchange"
380
+ },
381
+ {
382
+ "id": 50,
383
+ "methods": [{"id": 10,
384
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
385
+ {"domain": "queue-name", "name": "queue", "default-value": ""},
386
+ {"type": "bit", "name": "passive", "default-value": false},
387
+ {"type": "bit", "name": "durable", "default-value": false},
388
+ {"type": "bit", "name": "exclusive", "default-value": false},
389
+ {"type": "bit", "name": "auto-delete", "default-value": false},
390
+ {"type": "bit", "name": "nowait", "default-value": false},
391
+ {"type": "table", "name": "arguments", "default-value": {}}],
392
+ "name": "declare",
393
+ "synchronous" : true},
394
+ {"id": 11,
395
+ "arguments": [{"domain": "queue-name", "name": "queue"},
396
+ {"domain": "message-count", "name": "message-count"},
397
+ {"type": "long", "name": "consumer-count"}],
398
+ "name": "declare-ok"},
399
+ {"id": 20,
400
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
401
+ {"domain": "queue-name", "name": "queue", "default-value": ""},
402
+ {"domain": "exchange-name", "name": "exchange"},
403
+ {"type": "shortstr", "name": "routing-key", "default-value": ""},
404
+ {"type": "bit", "name": "nowait", "default-value": false},
405
+ {"type": "table", "name": "arguments", "default-value": {}}],
406
+ "name": "bind",
407
+ "synchronous" : true},
408
+ {"id": 21,
409
+ "arguments": [],
410
+ "name": "bind-ok"},
411
+ {"id": 30,
412
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
413
+ {"domain": "queue-name", "name": "queue", "default-value": ""},
414
+ {"type": "bit", "name": "nowait", "default-value": false}],
415
+ "name": "purge",
416
+ "synchronous" : true},
417
+ {"id": 31,
418
+ "arguments": [{"domain": "message-count", "name": "message-count"}],
419
+ "name": "purge-ok"},
420
+ {"id": 40,
421
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
422
+ {"domain": "queue-name", "name": "queue", "default-value": ""},
423
+ {"type": "bit", "name": "if-unused", "default-value": false},
424
+ {"type": "bit", "name": "if-empty", "default-value": false},
425
+ {"type": "bit", "name": "nowait", "default-value": false}],
426
+ "name": "delete",
427
+ "synchronous" : true},
428
+ {"id": 41,
429
+ "arguments": [{"domain": "message-count", "name": "message-count"}],
430
+ "name": "delete-ok"},
431
+ {"id": 50,
432
+ "arguments": [{"type": "short", "name": "ticket", "default-value": 0},
433
+ {"domain": "queue-name", "name": "queue", "default-value": ""},
434
+ {"domain": "exchange-name", "name": "exchange"},
435
+ {"type": "shortstr", "name": "routing-key", "default-value": ""},
436
+ {"type": "table", "name": "arguments", "default-value": {}}],
437
+ "name": "unbind",
438
+ "synchronous" : true},
439
+ {"id": 51,
440
+ "arguments": [],
441
+ "name": "unbind-ok"}
442
+ ],
443
+ "name": "queue"
444
+ },
445
+ {
446
+ "id": 90,
447
+ "methods": [{"id": 10,
448
+ "arguments": [],
449
+ "name": "select",
450
+ "synchronous" : true},
451
+ {"id": 11,
452
+ "arguments": [],
453
+ "name": "select-ok"},
454
+ {"id": 20,
455
+ "arguments": [],
456
+ "name": "commit",
457
+ "synchronous" : true},
458
+ {"id": 21,
459
+ "arguments": [],
460
+ "name": "commit-ok"},
461
+ {"id": 30,
462
+ "arguments": [],
463
+ "name": "rollback",
464
+ "synchronous" : true},
465
+ {"id": 31,
466
+ "arguments": [],
467
+ "name": "rollback-ok"}],
468
+ "name": "tx"
469
+ },
470
+ {
471
+ "id": 85,
472
+ "methods": [{"id": 10,
473
+ "arguments": [
474
+ {"type": "bit", "name": "nowait", "default-value": false}],
475
+ "name": "select",
476
+ "synchronous": true},
477
+ {"id": 11,
478
+ "arguments": [],
479
+ "name": "select-ok"}],
480
+ "name": "confirm"
481
+ }
482
+ ]
483
+ }
@@ -495,7 +495,7 @@ function decoderFn(method) {
495
495
  break;
496
496
  case 'longstr':
497
497
  println('len = buffer.readUInt32BE(offset); offset += 4;');
498
- println('val = buffer.slice(offset, offset + len);');
498
+ println('val = buffer.subarray(offset, offset + len);');
499
499
  println('offset += len;');
500
500
  break;
501
501
  case 'shortstr':
@@ -505,7 +505,7 @@ function decoderFn(method) {
505
505
  break;
506
506
  case 'table':
507
507
  println('len = buffer.readUInt32BE(offset); offset += 4;');
508
- println('val = decodeFields(buffer.slice(offset, offset + len));');
508
+ println('val = decodeFields(buffer.subarray(offset, offset + len));');
509
509
  println('offset += len;');
510
510
  break;
511
511
  default:
@@ -657,7 +657,7 @@ function encodePropsFn(props) {
657
657
  // size does not include the frame header or frame end byte
658
658
  println('buffer.writeUInt32BE(offset - 7, 3);');
659
659
  println('buffer.writeUInt16BE(flags, 19);');
660
- println('return buffer.slice(0, offset + 1);');
660
+ println('return buffer.subarray(0, offset + 1);');
661
661
  println('}');
662
662
  }
663
663
 
@@ -697,7 +697,7 @@ function decodePropsFn(props) {
697
697
  break;
698
698
  case 'longstr':
699
699
  println('len = buffer.readUInt32BE(offset); offset += 4;');
700
- println('val = buffer.slice(offset, offset + len);');
700
+ println('val = buffer.subarray(offset, offset + len);');
701
701
  println('offset += len;');
702
702
  break;
703
703
  case 'shortstr':
@@ -707,7 +707,7 @@ function decodePropsFn(props) {
707
707
  break;
708
708
  case 'table':
709
709
  println('len = buffer.readUInt32BE(offset); offset += 4;');
710
- println('val = decodeFields(buffer.slice(offset, offset + len));');
710
+ println('val = decodeFields(buffer.subarray(offset, offset + len));');
711
711
  println('offset += len;');
712
712
  break;
713
713
  default:
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+
3
+ const amqp = require('../');
4
+
5
+ const queue = 'rpc_queue';
6
+
7
+ (async () => {
8
+ const connection = await amqp.connect();
9
+ const channel = await connection.createChannel();
10
+
11
+ await channel.consume('amq.rabbitmq.reply-to', async (message) => {
12
+ console.log(message.content.toString());
13
+ await channel.close();
14
+ await connection.close();
15
+ }, { noAck: true });
16
+
17
+ await channel.assertQueue(queue, { durable: false });
18
+
19
+ channel.sendToQueue(queue, Buffer.from(' [X] ping'), {
20
+ replyTo: 'amq.rabbitmq.reply-to',
21
+ });
22
+ })();
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+
3
+ const amqp = require('../');
4
+ const { v4: uuid } = require('uuid');
5
+
6
+ const queue = 'rpc_queue';
7
+
8
+ (async () => {
9
+ const connection = await amqp.connect();
10
+ const channel = await connection.createChannel();
11
+
12
+ process.once('SIGINT', async () => {
13
+ await channel.close();
14
+ await connection.close();
15
+ });
16
+
17
+ await channel.assertQueue(queue, { durable: false });
18
+ await channel.consume(queue, (message) => {
19
+ console.log(message.content.toString());
20
+ channel.sendToQueue(message.properties.replyTo, Buffer.from(' [.] pong'));
21
+ }, { noAck: true });
22
+
23
+ console.log(' [x] To exit press CTRL+C.');
24
+
25
+ })();