@amqp-contract/contract 0.20.0 → 0.22.0
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.
- package/README.md +34 -4
- package/dist/index.cjs +332 -390
- package/dist/index.d.cts +657 -622
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +657 -622
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +331 -385
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +413 -529
- package/package.json +24 -24
package/docs/index.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
type AnySchema = StandardSchemaV1;
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Defined in: [types.ts:12](https://github.com/btravers/amqp-contract/blob/
|
|
15
|
+
Defined in: [types.ts:12](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L12)
|
|
16
16
|
|
|
17
17
|
Any schema that conforms to Standard Schema v1.
|
|
18
18
|
|
|
@@ -32,7 +32,7 @@ https://github.com/standard-schema/standard-schema
|
|
|
32
32
|
type BaseExchangeDefinition<TName> = object;
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Defined in: [types.ts:
|
|
35
|
+
Defined in: [types.ts:394](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L394)
|
|
36
36
|
|
|
37
37
|
Base definition of an AMQP exchange.
|
|
38
38
|
|
|
@@ -49,11 +49,11 @@ type and routing rules. This type contains properties common to all exchange typ
|
|
|
49
49
|
|
|
50
50
|
| Property | Type | Description | Defined in |
|
|
51
51
|
| ------ | ------ | ------ | ------ |
|
|
52
|
-
| <a id="arguments"></a> `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for advanced configuration. Common arguments include alternate-exchange for handling unroutable messages. | [types.ts:
|
|
53
|
-
| <a id="autodelete"></a> `autoDelete?` | `boolean` | If true, the exchange is deleted when all queues have finished using it.
|
|
54
|
-
| <a id="durable"></a> `durable?` | `boolean` | If true, the exchange survives broker restarts. Durable exchanges are persisted to disk. **Default** `
|
|
55
|
-
| <a id="internal"></a> `internal?` | `boolean` | If true, the exchange cannot be directly published to by clients. It can only receive messages from other exchanges via exchange-to-exchange bindings.
|
|
56
|
-
| <a id="name"></a> `name` | `TName` | The name of the exchange. Must be unique within the RabbitMQ virtual host. | [types.ts:
|
|
52
|
+
| <a id="arguments"></a> `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for advanced configuration. Common arguments include alternate-exchange for handling unroutable messages. | [types.ts:421](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L421) |
|
|
53
|
+
| <a id="autodelete"></a> `autoDelete?` | `boolean` | If true, the exchange is deleted when all queues have finished using it. | [types.ts:409](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L409) |
|
|
54
|
+
| <a id="durable"></a> `durable?` | `boolean` | If true, the exchange survives broker restarts. Durable exchanges are persisted to disk. **Default** `true` | [types.ts:404](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L404) |
|
|
55
|
+
| <a id="internal"></a> `internal?` | `boolean` | If true, the exchange cannot be directly published to by clients. It can only receive messages from other exchanges via exchange-to-exchange bindings. | [types.ts:415](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L415) |
|
|
56
|
+
| <a id="name"></a> `name` | `TName` | The name of the exchange. Must be unique within the RabbitMQ virtual host. | [types.ts:398](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L398) |
|
|
57
57
|
|
|
58
58
|
***
|
|
59
59
|
|
|
@@ -65,7 +65,7 @@ type BindingDefinition =
|
|
|
65
65
|
| ExchangeBindingDefinition;
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
Defined in: [types.ts:
|
|
68
|
+
Defined in: [types.ts:891](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L891)
|
|
69
69
|
|
|
70
70
|
Union type of all binding definitions.
|
|
71
71
|
|
|
@@ -81,7 +81,7 @@ A binding can be either:
|
|
|
81
81
|
type BindingPattern<S> = S extends "" ? never : S;
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
Defined in: [builder/routing-types.ts:52](https://github.com/btravers/amqp-contract/blob/
|
|
84
|
+
Defined in: [builder/routing-types.ts:52](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/routing-types.ts#L52)
|
|
85
85
|
|
|
86
86
|
Type-safe binding pattern that validates basic format and wildcards.
|
|
87
87
|
|
|
@@ -116,7 +116,7 @@ type Invalid = BindingPattern<"">; // never (empty string)
|
|
|
116
116
|
type BridgedPublisherConfig<TMessage, TBridgeExchange, TTargetExchange> = object;
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
Defined in: [builder/command.ts:
|
|
119
|
+
Defined in: [builder/command.ts:61](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L61)
|
|
120
120
|
|
|
121
121
|
Configuration for a bridged command publisher.
|
|
122
122
|
|
|
@@ -135,11 +135,11 @@ messages to the target exchange (remote domain) via an exchange-to-exchange bind
|
|
|
135
135
|
|
|
136
136
|
| Property | Type | Description | Defined in |
|
|
137
137
|
| ------ | ------ | ------ | ------ |
|
|
138
|
-
| <a id="__brand"></a> `__brand` | `"BridgedPublisherConfig"` | Discriminator to identify this as a bridged publisher config | [builder/command.ts:
|
|
139
|
-
| <a id="bridgeexchange"></a> `bridgeExchange` | `TBridgeExchange` | The bridge (local domain) exchange | [builder/command.ts:
|
|
140
|
-
| <a id="exchangebinding"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) | The exchange-to-exchange binding (bridge → target) | [builder/command.ts:
|
|
141
|
-
| <a id="publisher"></a> `publisher` | [`PublisherDefinition`](#publisherdefinition)<`TMessage`> | The publisher definition (publishes to bridge exchange) | [builder/command.ts:
|
|
142
|
-
| <a id="targetexchange"></a> `targetExchange` | `TTargetExchange` | The target (remote domain) exchange | [builder/command.ts:
|
|
138
|
+
| <a id="__brand"></a> `__brand` | `"BridgedPublisherConfig"` | Discriminator to identify this as a bridged publisher config | [builder/command.ts:67](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L67) |
|
|
139
|
+
| <a id="bridgeexchange"></a> `bridgeExchange` | `TBridgeExchange` | The bridge (local domain) exchange | [builder/command.ts:73](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L73) |
|
|
140
|
+
| <a id="exchangebinding"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) | The exchange-to-exchange binding (bridge → target) | [builder/command.ts:71](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L71) |
|
|
141
|
+
| <a id="publisher"></a> `publisher` | [`PublisherDefinition`](#publisherdefinition)<`TMessage`> | The publisher definition (publishes to bridge exchange) | [builder/command.ts:69](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L69) |
|
|
142
|
+
| <a id="targetexchange"></a> `targetExchange` | `TTargetExchange` | The target (remote domain) exchange | [builder/command.ts:75](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L75) |
|
|
143
143
|
|
|
144
144
|
***
|
|
145
145
|
|
|
@@ -149,7 +149,7 @@ messages to the target exchange (remote domain) via an exchange-to-exchange bind
|
|
|
149
149
|
type BridgedPublisherConfigBase = object;
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
Defined in: [types.ts:
|
|
152
|
+
Defined in: [types.ts:1024](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1024)
|
|
153
153
|
|
|
154
154
|
Base type for bridged publisher configuration.
|
|
155
155
|
|
|
@@ -164,11 +164,11 @@ defineCommandPublisher with bridgeExchange option
|
|
|
164
164
|
|
|
165
165
|
| Property | Type | Defined in |
|
|
166
166
|
| ------ | ------ | ------ |
|
|
167
|
-
| <a id="__brand-1"></a> `__brand` | `"BridgedPublisherConfig"` | [types.ts:
|
|
168
|
-
| <a id="bridgeexchange-1"></a> `bridgeExchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:
|
|
169
|
-
| <a id="exchangebinding-1"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) | [types.ts:
|
|
170
|
-
| <a id="publisher-1"></a> `publisher` | [`PublisherDefinition`](#publisherdefinition) | [types.ts:
|
|
171
|
-
| <a id="targetexchange-1"></a> `targetExchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:
|
|
167
|
+
| <a id="__brand-1"></a> `__brand` | `"BridgedPublisherConfig"` | [types.ts:1025](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1025) |
|
|
168
|
+
| <a id="bridgeexchange-1"></a> `bridgeExchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:1028](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1028) |
|
|
169
|
+
| <a id="exchangebinding-1"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) | [types.ts:1027](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1027) |
|
|
170
|
+
| <a id="publisher-1"></a> `publisher` | [`PublisherDefinition`](#publisherdefinition) | [types.ts:1026](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1026) |
|
|
171
|
+
| <a id="targetexchange-1"></a> `targetExchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:1029](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1029) |
|
|
172
172
|
|
|
173
173
|
***
|
|
174
174
|
|
|
@@ -178,21 +178,22 @@ defineCommandPublisher with bridgeExchange option
|
|
|
178
178
|
type ClassicQueueDefinition<TName> = BaseQueueDefinition<TName> & object;
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
Defined in: [types.ts:
|
|
181
|
+
Defined in: [types.ts:608](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L608)
|
|
182
182
|
|
|
183
183
|
Definition of a classic queue.
|
|
184
184
|
|
|
185
185
|
Classic queues are the traditional RabbitMQ queue type. Use them when you need
|
|
186
|
-
specific features not supported by quorum queues (e.g., exclusive queues, priority queues).
|
|
186
|
+
specific features not supported by quorum queues (e.g., exclusive queues, auto-deleting queues, priority queues).
|
|
187
187
|
|
|
188
188
|
#### Type Declaration
|
|
189
189
|
|
|
190
190
|
| Name | Type | Description | Defined in |
|
|
191
191
|
| ------ | ------ | ------ | ------ |
|
|
192
|
-
| `
|
|
193
|
-
| `
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
192
|
+
| `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. | [types.ts:628](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L628) |
|
|
193
|
+
| `durable` | `boolean` | If true, the queue survives broker restarts. Durable queues are persisted to disk. | [types.ts:617](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L617) |
|
|
194
|
+
| `exclusive?` | `boolean` | If true, the queue can only be used by the declaring connection and is deleted when that connection closes. Exclusive queues are private to the connection. | [types.ts:623](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L623) |
|
|
195
|
+
| `maxPriority?` | `number` | Maximum priority level for priority queue (1-255, recommended: 1-10). Sets x-max-priority argument. | [types.ts:634](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L634) |
|
|
196
|
+
| `type` | `"classic"` | Queue type discriminator: classic queue. | [types.ts:612](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L612) |
|
|
196
197
|
|
|
197
198
|
#### Type Parameters
|
|
198
199
|
|
|
@@ -208,12 +209,13 @@ specific features not supported by quorum queues (e.g., exclusive queues, priori
|
|
|
208
209
|
type ClassicQueueOptions = BaseQueueOptions & object;
|
|
209
210
|
```
|
|
210
211
|
|
|
211
|
-
Defined in: [types.ts:
|
|
212
|
+
Defined in: [types.ts:342](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L342)
|
|
212
213
|
|
|
213
214
|
Options for creating a classic queue.
|
|
214
215
|
|
|
215
216
|
Classic queues support all traditional RabbitMQ features including:
|
|
216
|
-
- `exclusive
|
|
217
|
+
- `exclusive` - For connection-scoped queues
|
|
218
|
+
- `autoDelete` - For auto-deleting queues when consumers disconnect
|
|
217
219
|
- `maxPriority` - For priority queues
|
|
218
220
|
- `durable: false` - For non-durable queues
|
|
219
221
|
|
|
@@ -221,17 +223,17 @@ Classic queues support all traditional RabbitMQ features including:
|
|
|
221
223
|
|
|
222
224
|
| Name | Type | Description | Defined in |
|
|
223
225
|
| ------ | ------ | ------ | ------ |
|
|
224
|
-
| `
|
|
225
|
-
| `
|
|
226
|
-
| `
|
|
227
|
-
| `
|
|
226
|
+
| `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. | [types.ts:363](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L363) |
|
|
227
|
+
| `durable?` | `boolean` | If true, the queue survives broker restarts. Durable queues are persisted to disk. **Default** `true` | [types.ts:352](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L352) |
|
|
228
|
+
| `exclusive?` | `boolean` | If true, the queue can only be used by the declaring connection and is deleted when that connection closes. Exclusive queues are private to the connection. | [types.ts:358](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L358) |
|
|
229
|
+
| `maxPriority?` | `number` | Maximum priority level for priority queue (1-255, recommended: 1-10). Sets x-max-priority argument. | [types.ts:369](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L369) |
|
|
230
|
+
| `type` | `"classic"` | Queue type: classic (for special cases) | [types.ts:346](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L346) |
|
|
228
231
|
|
|
229
232
|
#### Example
|
|
230
233
|
|
|
231
234
|
```typescript
|
|
232
235
|
const priorityQueue = defineQueue('tasks', {
|
|
233
236
|
type: 'classic',
|
|
234
|
-
durable: true,
|
|
235
237
|
maxPriority: 10,
|
|
236
238
|
});
|
|
237
239
|
```
|
|
@@ -241,10 +243,10 @@ const priorityQueue = defineQueue('tasks', {
|
|
|
241
243
|
### CommandConsumerConfig
|
|
242
244
|
|
|
243
245
|
```ts
|
|
244
|
-
type CommandConsumerConfig<TMessage, TExchange, TRoutingKey, TQueue
|
|
246
|
+
type CommandConsumerConfig<TMessage, TExchange, TRoutingKey, TQueue> = object;
|
|
245
247
|
```
|
|
246
248
|
|
|
247
|
-
Defined in: [builder/command.ts:
|
|
249
|
+
Defined in: [builder/command.ts:29](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L29)
|
|
248
250
|
|
|
249
251
|
Configuration for a command consumer.
|
|
250
252
|
|
|
@@ -257,22 +259,20 @@ The consumer "owns" the queue, and publishers send commands to it.
|
|
|
257
259
|
| ------ | ------ | ------ |
|
|
258
260
|
| `TMessage` *extends* [`MessageDefinition`](#messagedefinition) | - | The message definition |
|
|
259
261
|
| `TExchange` *extends* [`ExchangeDefinition`](#exchangedefinition) | - | The exchange definition |
|
|
260
|
-
| `TRoutingKey` *extends* `string` \| `undefined` | `undefined` | The routing key type (undefined for fanout) |
|
|
261
|
-
| `TQueue` *extends* [`
|
|
262
|
-
| `TDlxExchange` *extends* [`ExchangeDefinition`](#exchangedefinition) \| `undefined` | [`ExchangeDefinition`](#exchangedefinition) \| `undefined` | - |
|
|
262
|
+
| `TRoutingKey` *extends* `string` \| `undefined` | `undefined` | The routing key type (undefined for fanout and headers exchanges) |
|
|
263
|
+
| `TQueue` *extends* [`QueueEntry`](#queueentry) | [`QueueEntry`](#queueentry) | - |
|
|
263
264
|
|
|
264
265
|
#### Properties
|
|
265
266
|
|
|
266
267
|
| Property | Type | Description | Defined in |
|
|
267
268
|
| ------ | ------ | ------ | ------ |
|
|
268
|
-
| <a id="__brand-2"></a> `__brand` | `"CommandConsumerConfig"` | Discriminator to identify this as a command consumer config | [builder/command.ts:
|
|
269
|
-
| <a id="binding"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | The binding connecting the queue to the exchange | [builder/command.ts:
|
|
270
|
-
| <a id="consumer"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition)<`TMessage`> | The consumer definition for processing commands | [builder/command.ts:
|
|
271
|
-
| <a id="
|
|
272
|
-
| <a id="
|
|
273
|
-
| <a id="
|
|
274
|
-
| <a id="
|
|
275
|
-
| <a id="routingkey"></a> `routingKey` | `TRoutingKey` | The routing key pattern for the binding | [builder/command.ts:53](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/command.ts#L53) |
|
|
269
|
+
| <a id="__brand-2"></a> `__brand` | `"CommandConsumerConfig"` | Discriminator to identify this as a command consumer config | [builder/command.ts:36](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L36) |
|
|
270
|
+
| <a id="binding"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | The binding connecting the queue to the exchange | [builder/command.ts:40](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L40) |
|
|
271
|
+
| <a id="consumer"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition)<`TMessage`> | The consumer definition for processing commands | [builder/command.ts:38](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L38) |
|
|
272
|
+
| <a id="exchange"></a> `exchange` | `TExchange` | The exchange that receives commands | [builder/command.ts:42](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L42) |
|
|
273
|
+
| <a id="message"></a> `message` | `TMessage` | The message definition | [builder/command.ts:46](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L46) |
|
|
274
|
+
| <a id="queue"></a> `queue` | `TQueue` | The queue this consumer reads from | [builder/command.ts:44](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L44) |
|
|
275
|
+
| <a id="routingkey"></a> `routingKey` | `TRoutingKey` | The routing key pattern for the binding | [builder/command.ts:48](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L48) |
|
|
276
276
|
|
|
277
277
|
***
|
|
278
278
|
|
|
@@ -282,7 +282,7 @@ The consumer "owns" the queue, and publishers send commands to it.
|
|
|
282
282
|
type CommandConsumerConfigBase = object;
|
|
283
283
|
```
|
|
284
284
|
|
|
285
|
-
Defined in: [types.ts:
|
|
285
|
+
Defined in: [types.ts:988](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L988)
|
|
286
286
|
|
|
287
287
|
Base type for command consumer configuration.
|
|
288
288
|
|
|
@@ -297,14 +297,13 @@ defineCommandConsumer for creating command consumers
|
|
|
297
297
|
|
|
298
298
|
| Property | Type | Defined in |
|
|
299
299
|
| ------ | ------ | ------ |
|
|
300
|
-
| <a id="__brand-3"></a> `__brand` | `"CommandConsumerConfig"` | [types.ts:
|
|
301
|
-
| <a id="binding-1"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | [types.ts:
|
|
302
|
-
| <a id="consumer-1"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition) | [types.ts:
|
|
303
|
-
| <a id="
|
|
304
|
-
| <a id="
|
|
305
|
-
| <a id="
|
|
306
|
-
| <a id="
|
|
307
|
-
| <a id="routingkey-1"></a> `routingKey` | `string` \| `undefined` | [types.ts:938](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/types.ts#L938) |
|
|
300
|
+
| <a id="__brand-3"></a> `__brand` | `"CommandConsumerConfig"` | [types.ts:989](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L989) |
|
|
301
|
+
| <a id="binding-1"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | [types.ts:991](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L991) |
|
|
302
|
+
| <a id="consumer-1"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition) | [types.ts:990](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L990) |
|
|
303
|
+
| <a id="exchange-1"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:992](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L992) |
|
|
304
|
+
| <a id="message-1"></a> `message` | [`MessageDefinition`](#messagedefinition) | [types.ts:994](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L994) |
|
|
305
|
+
| <a id="queue-1"></a> `queue` | [`QueueEntry`](#queueentry) | [types.ts:993](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L993) |
|
|
306
|
+
| <a id="routingkey-1"></a> `routingKey` | `string` \| `undefined` | [types.ts:995](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L995) |
|
|
308
307
|
|
|
309
308
|
***
|
|
310
309
|
|
|
@@ -314,7 +313,7 @@ defineCommandConsumer for creating command consumers
|
|
|
314
313
|
type CompressionAlgorithm = "gzip" | "deflate";
|
|
315
314
|
```
|
|
316
315
|
|
|
317
|
-
Defined in: [types.ts:
|
|
316
|
+
Defined in: [types.ts:199](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L199)
|
|
318
317
|
|
|
319
318
|
Supported compression algorithms for message payloads.
|
|
320
319
|
|
|
@@ -352,7 +351,7 @@ await client.publish("orderCreated", payload, {
|
|
|
352
351
|
type ConsumerDefinition<TMessage> = object;
|
|
353
352
|
```
|
|
354
353
|
|
|
355
|
-
Defined in: [types.ts:
|
|
354
|
+
Defined in: [types.ts:952](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L952)
|
|
356
355
|
|
|
357
356
|
Definition of a message consumer.
|
|
358
357
|
|
|
@@ -380,8 +379,8 @@ const consumer: ConsumerDefinition = {
|
|
|
380
379
|
|
|
381
380
|
| Property | Type | Description | Defined in |
|
|
382
381
|
| ------ | ------ | ------ | ------ |
|
|
383
|
-
| <a id="message-2"></a> `message` | `TMessage` | The message definition including the payload schema | [types.ts:
|
|
384
|
-
| <a id="queue-2"></a> `queue` | [`
|
|
382
|
+
| <a id="message-2"></a> `message` | `TMessage` | The message definition including the payload schema | [types.ts:957](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L957) |
|
|
383
|
+
| <a id="queue-2"></a> `queue` | [`QueueEntry`](#queueentry) | The queue to consume messages from | [types.ts:954](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L954) |
|
|
385
384
|
|
|
386
385
|
***
|
|
387
386
|
|
|
@@ -394,7 +393,7 @@ type ConsumerEntry =
|
|
|
394
393
|
| CommandConsumerConfigBase;
|
|
395
394
|
```
|
|
396
395
|
|
|
397
|
-
Defined in: [types.ts:
|
|
396
|
+
Defined in: [types.ts:1162](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1162)
|
|
398
397
|
|
|
399
398
|
Consumer entry that can be passed to defineContract's consumers section.
|
|
400
399
|
|
|
@@ -411,7 +410,7 @@ Can be either:
|
|
|
411
410
|
type ContractDefinition = object;
|
|
412
411
|
```
|
|
413
412
|
|
|
414
|
-
Defined in: [types.ts:
|
|
413
|
+
Defined in: [types.ts:1093](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1093)
|
|
415
414
|
|
|
416
415
|
Complete AMQP contract definition (output type).
|
|
417
416
|
|
|
@@ -450,11 +449,12 @@ const contract: ContractDefinition = {
|
|
|
450
449
|
|
|
451
450
|
| Property | Type | Description | Defined in |
|
|
452
451
|
| ------ | ------ | ------ | ------ |
|
|
453
|
-
| <a id="bindings"></a> `bindings?` | `Record`<`string`, [`BindingDefinition`](#bindingdefinition)> | Named binding definitions. Bindings can be queue-to-exchange or exchange-to-exchange. | [types.ts:
|
|
454
|
-
| <a id="consumers"></a> `consumers?` | `Record`<`string`, [`ConsumerDefinition`](#consumerdefinition)> | Named consumer definitions. Each key requires a corresponding handler in the TypedAmqpWorker. The handler will be fully typed based on the message schema. | [types.ts:
|
|
455
|
-
| <a id="exchanges"></a> `exchanges?` | `Record`<`string`, [`ExchangeDefinition`](#exchangedefinition)> | Named exchange definitions. Each key becomes available as a named resource in the contract. | [types.ts:
|
|
456
|
-
| <a id="publishers"></a> `publishers?` | `Record`<`string`, [`PublisherDefinition`](#publisherdefinition)> | Named publisher definitions. Each key becomes a method on the TypedAmqpClient for publishing messages. The method will be fully typed based on the message schema. | [types.ts:
|
|
457
|
-
| <a id="queues"></a> `queues?` | `Record`<`string`, [`QueueEntry`](#queueentry)> | Named queue definitions. Each key becomes available as a named resource in the contract. When a queue has TTL-backoff retry configured, pass the `QueueWithTtlBackoffInfrastructure` object returned by `defineQueue`. The wait queue and bindings will be automatically added. | [types.ts:
|
|
452
|
+
| <a id="bindings"></a> `bindings?` | `Record`<`string`, [`BindingDefinition`](#bindingdefinition)> | Named binding definitions. Bindings can be queue-to-exchange or exchange-to-exchange. | [types.ts:1113](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1113) |
|
|
453
|
+
| <a id="consumers"></a> `consumers?` | `Record`<`string`, [`ConsumerDefinition`](#consumerdefinition)> | Named consumer definitions. Each key requires a corresponding handler in the TypedAmqpWorker. The handler will be fully typed based on the message schema. | [types.ts:1127](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1127) |
|
|
454
|
+
| <a id="exchanges"></a> `exchanges?` | `Record`<`string`, [`ExchangeDefinition`](#exchangedefinition)> | Named exchange definitions. Each key becomes available as a named resource in the contract. | [types.ts:1098](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1098) |
|
|
455
|
+
| <a id="publishers"></a> `publishers?` | `Record`<`string`, [`PublisherDefinition`](#publisherdefinition)> | Named publisher definitions. Each key becomes a method on the TypedAmqpClient for publishing messages. The method will be fully typed based on the message schema. | [types.ts:1120](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1120) |
|
|
456
|
+
| <a id="queues"></a> `queues?` | `Record`<`string`, [`QueueEntry`](#queueentry)> | Named queue definitions. Each key becomes available as a named resource in the contract. When a queue has TTL-backoff retry configured, pass the `QueueWithTtlBackoffInfrastructure` object returned by `defineQueue`. The wait queue, exchanges, and bindings will be automatically added. | [types.ts:1107](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1107) |
|
|
457
|
+
| <a id="rpcs"></a> `rpcs?` | `Record`<`string`, [`RpcDefinition`](#rpcdefinition)> | Named RPC definitions. Each key gets: - A handler in the TypedAmqpWorker that returns the typed response. - A `client.call(name, request, options)` method on the TypedAmqpClient. RPC entries do not appear in `publishers` or `consumers` because each end of an RPC plays both roles (publisher of one direction, consumer of the other). | [types.ts:1138](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1138) |
|
|
458
458
|
|
|
459
459
|
***
|
|
460
460
|
|
|
@@ -464,7 +464,7 @@ const contract: ContractDefinition = {
|
|
|
464
464
|
type ContractDefinitionInput = object;
|
|
465
465
|
```
|
|
466
466
|
|
|
467
|
-
Defined in: [types.ts:
|
|
467
|
+
Defined in: [types.ts:1191](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1191)
|
|
468
468
|
|
|
469
469
|
Contract definition input type with automatic extraction of event/command patterns.
|
|
470
470
|
|
|
@@ -496,8 +496,9 @@ defineContract - Processes this input and returns a ContractDefinition
|
|
|
496
496
|
|
|
497
497
|
| Property | Type | Description | Defined in |
|
|
498
498
|
| ------ | ------ | ------ | ------ |
|
|
499
|
-
| <a id="consumers-1"></a> `consumers?` | `Record`<`string`, [`ConsumerEntry`](#consumerentry)> | Named consumer definitions. Can accept: - ConsumerDefinition from defineConsumer - EventConsumerResult from defineEventConsumer (binding auto-extracted) - CommandConsumerConfig from defineCommandConsumer (binding auto-extracted) | [types.ts:
|
|
500
|
-
| <a id="publishers-1"></a> `publishers?` | `Record`<`string`, [`PublisherEntry`](#publisherentry)> | Named publisher definitions. Can accept: - PublisherDefinition from definePublisher - EventPublisherConfig from defineEventPublisher (auto-extracted to publisher) | [types.ts:
|
|
499
|
+
| <a id="consumers-1"></a> `consumers?` | `Record`<`string`, [`ConsumerEntry`](#consumerentry)> | Named consumer definitions. Can accept: - ConsumerDefinition from defineConsumer - EventConsumerResult from defineEventConsumer (binding auto-extracted) - CommandConsumerConfig from defineCommandConsumer (binding auto-extracted) | [types.ts:1209](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1209) |
|
|
500
|
+
| <a id="publishers-1"></a> `publishers?` | `Record`<`string`, [`PublisherEntry`](#publisherentry)> | Named publisher definitions. Can accept: - PublisherDefinition from definePublisher - EventPublisherConfig from defineEventPublisher (auto-extracted to publisher) | [types.ts:1199](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1199) |
|
|
501
|
+
| <a id="rpcs-1"></a> `rpcs?` | `Record`<`string`, [`RpcDefinition`](#rpcdefinition)> | Named RPC definitions from `defineRpc`. Each entry contributes its queue (and DLX if any) to the contract topology and exposes a typed `client.call(name, ...)` / worker handler pair. | [types.ts:1216](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1216) |
|
|
501
502
|
|
|
502
503
|
***
|
|
503
504
|
|
|
@@ -507,7 +508,7 @@ defineContract - Processes this input and returns a ContractDefinition
|
|
|
507
508
|
type ContractOutput<TContract> = object;
|
|
508
509
|
```
|
|
509
510
|
|
|
510
|
-
Defined in: [types.ts:
|
|
511
|
+
Defined in: [types.ts:1533](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1533)
|
|
511
512
|
|
|
512
513
|
Contract output type with all resources extracted and properly typed.
|
|
513
514
|
|
|
@@ -528,11 +529,12 @@ This type represents the fully expanded contract with:
|
|
|
528
529
|
|
|
529
530
|
| Property | Type | Defined in |
|
|
530
531
|
| ------ | ------ | ------ |
|
|
531
|
-
| <a id="bindings-1"></a> `bindings` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractBindingsFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractExchangeBindingsFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractExchangeBindingsFromPublishers`<`TContract`\[`"publishers"`\]> : `object` | [types.ts:
|
|
532
|
-
| <a id="consumers-2"></a> `consumers` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractConsumerDefinitions`<`TContract`\[`"consumers"`\]> : `object` | [types.ts:
|
|
533
|
-
| <a id="exchanges-1"></a> `exchanges` | `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractExchangesFromPublishers`<`TContract`\[`"publishers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractDeadLetterExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractBridgeExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractTargetExchangesFromPublishers`<`TContract`\[`"publishers"`\]> : `object` | [types.ts:
|
|
534
|
-
| <a id="publishers-2"></a> `publishers` | `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractPublisherDefinitions`<`TContract`\[`"publishers"`\]> : `object` | [types.ts:
|
|
535
|
-
| <a id="queues-1"></a> `queues` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractQueuesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` | [types.ts:
|
|
532
|
+
| <a id="bindings-1"></a> `bindings` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractBindingsFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractExchangeBindingsFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractExchangeBindingsFromPublishers`<`TContract`\[`"publishers"`\]> : `object` | [types.ts:1558](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1558) |
|
|
533
|
+
| <a id="consumers-2"></a> `consumers` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractConsumerDefinitions`<`TContract`\[`"consumers"`\]> : `object` | [types.ts:1570](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1570) |
|
|
534
|
+
| <a id="exchanges-1"></a> `exchanges` | `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractExchangesFromPublishers`<`TContract`\[`"publishers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractDeadLetterExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractBridgeExchangesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractTargetExchangesFromPublishers`<`TContract`\[`"publishers"`\]> : `object` & `TContract`\[`"rpcs"`\] *extends* `Record`<`string`, [`RpcDefinition`](#rpcdefinition)> ? `ExtractDeadLetterExchangesFromRpcs`<`TContract`\[`"rpcs"`\]> : `object` | [types.ts:1534](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1534) |
|
|
535
|
+
| <a id="publishers-2"></a> `publishers` | `TContract`\[`"publishers"`\] *extends* `Record`<`string`, [`PublisherEntry`](#publisherentry)> ? `ExtractPublisherDefinitions`<`TContract`\[`"publishers"`\]> : `object` | [types.ts:1567](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1567) |
|
|
536
|
+
| <a id="queues-1"></a> `queues` | `TContract`\[`"consumers"`\] *extends* `Record`<`string`, [`ConsumerEntry`](#consumerentry)> ? `ExtractQueuesFromConsumers`<`TContract`\[`"consumers"`\]> : `object` & `TContract`\[`"rpcs"`\] *extends* `Record`<`string`, [`RpcDefinition`](#rpcdefinition)> ? `ExtractQueuesFromRpcs`<`TContract`\[`"rpcs"`\]> : `object` | [types.ts:1552](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1552) |
|
|
537
|
+
| <a id="rpcs-2"></a> `rpcs` | `TContract`\[`"rpcs"`\] *extends* `Record`<`string`, [`RpcDefinition`](#rpcdefinition)> ? `TContract`\[`"rpcs"`\] : `object` | [types.ts:1573](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1573) |
|
|
536
538
|
|
|
537
539
|
***
|
|
538
540
|
|
|
@@ -542,7 +544,7 @@ This type represents the fully expanded contract with:
|
|
|
542
544
|
type DeadLetterConfig = object;
|
|
543
545
|
```
|
|
544
546
|
|
|
545
|
-
Defined in: [types.ts:
|
|
547
|
+
Defined in: [types.ts:518](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L518)
|
|
546
548
|
|
|
547
549
|
Configuration for dead letter exchange (DLX) on a queue.
|
|
548
550
|
|
|
@@ -554,8 +556,8 @@ or storage.
|
|
|
554
556
|
|
|
555
557
|
| Property | Type | Description | Defined in |
|
|
556
558
|
| ------ | ------ | ------ | ------ |
|
|
557
|
-
| <a id="exchange-2"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | The exchange to send dead-lettered messages to. This exchange must be declared in the contract. | [types.ts:
|
|
558
|
-
| <a id="routingkey-2"></a> `routingKey?` | `string` | Optional routing key to use when forwarding messages to the dead letter exchange. If not specified, the original message routing key is used. | [types.ts:
|
|
559
|
+
| <a id="exchange-2"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | The exchange to send dead-lettered messages to. This exchange must be declared in the contract. | [types.ts:523](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L523) |
|
|
560
|
+
| <a id="routingkey-2"></a> `routingKey?` | `string` | Optional routing key to use when forwarding messages to the dead letter exchange. If not specified, the original message routing key is used. | [types.ts:529](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L529) |
|
|
559
561
|
|
|
560
562
|
***
|
|
561
563
|
|
|
@@ -567,67 +569,13 @@ type DefineQueueOptions =
|
|
|
567
569
|
| ClassicQueueOptions;
|
|
568
570
|
```
|
|
569
571
|
|
|
570
|
-
Defined in: [types.ts:
|
|
572
|
+
Defined in: [types.ts:379](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L379)
|
|
571
573
|
|
|
572
574
|
Options for defining a queue. Uses a discriminated union based on the `type` property
|
|
573
575
|
to enforce quorum queue constraints at compile time.
|
|
574
576
|
|
|
575
|
-
- Quorum queues (default): Do not support `exclusive` or `maxPriority`
|
|
576
|
-
- Classic queues: Support all options including `exclusive` and `maxPriority`
|
|
577
|
-
|
|
578
|
-
***
|
|
579
|
-
|
|
580
|
-
### DefineQuorumQueueOptions
|
|
581
|
-
|
|
582
|
-
```ts
|
|
583
|
-
type DefineQuorumQueueOptions = object;
|
|
584
|
-
```
|
|
585
|
-
|
|
586
|
-
Defined in: [builder/queue.ts:399](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L399)
|
|
587
|
-
|
|
588
|
-
Options for creating a quorum queue with quorum-native retry.
|
|
589
|
-
|
|
590
|
-
This simplified helper enforces the required configuration for quorum-native retry:
|
|
591
|
-
- Dead letter exchange is required (for failed messages)
|
|
592
|
-
- Delivery limit is required (for retry count)
|
|
593
|
-
|
|
594
|
-
#### Properties
|
|
595
|
-
|
|
596
|
-
| Property | Type | Description | Defined in |
|
|
597
|
-
| ------ | ------ | ------ | ------ |
|
|
598
|
-
| <a id="arguments-1"></a> `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for advanced configuration. | [builder/queue.ts:421](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L421) |
|
|
599
|
-
| <a id="autodelete-1"></a> `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. **Default** `false` | [builder/queue.ts:416](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L416) |
|
|
600
|
-
| <a id="deadletter"></a> `deadLetter` | [`DeadLetterConfig`](#deadletterconfig) | Dead letter configuration - required for retry support. Failed messages will be sent to this exchange. | [builder/queue.ts:404](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L404) |
|
|
601
|
-
| <a id="deliverylimit"></a> `deliveryLimit` | `number` | Maximum number of delivery attempts before dead-lettering. **Minimum** 1 | [builder/queue.ts:410](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L410) |
|
|
602
|
-
|
|
603
|
-
***
|
|
604
|
-
|
|
605
|
-
### DefineTtlBackoffQueueOptions
|
|
606
|
-
|
|
607
|
-
```ts
|
|
608
|
-
type DefineTtlBackoffQueueOptions = object;
|
|
609
|
-
```
|
|
610
|
-
|
|
611
|
-
Defined in: [builder/queue.ts:486](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L486)
|
|
612
|
-
|
|
613
|
-
Options for creating a queue with TTL-backoff retry.
|
|
614
|
-
|
|
615
|
-
This simplified helper enforces the required configuration for TTL-backoff retry:
|
|
616
|
-
- Dead letter exchange is required (used for retry routing)
|
|
617
|
-
- Returns infrastructure that includes wait queue and bindings
|
|
618
|
-
|
|
619
|
-
#### Properties
|
|
620
|
-
|
|
621
|
-
| Property | Type | Description | Defined in |
|
|
622
|
-
| ------ | ------ | ------ | ------ |
|
|
623
|
-
| <a id="arguments-2"></a> `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for advanced configuration. | [builder/queue.ts:532](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L532) |
|
|
624
|
-
| <a id="autodelete-2"></a> `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. **Default** `false` | [builder/queue.ts:527](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L527) |
|
|
625
|
-
| <a id="backoffmultiplier"></a> `backoffMultiplier?` | `number` | Exponential backoff multiplier. **Default** `2` | [builder/queue.ts:515](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L515) |
|
|
626
|
-
| <a id="deadletter-1"></a> `deadLetter` | [`DeadLetterConfig`](#deadletterconfig) | Dead letter configuration - required for TTL-backoff retry. Used for routing messages to the wait queue and back. | [builder/queue.ts:491](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L491) |
|
|
627
|
-
| <a id="initialdelayms"></a> `initialDelayMs?` | `number` | Initial delay in ms before first retry. **Default** `1000` | [builder/queue.ts:503](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L503) |
|
|
628
|
-
| <a id="jitter"></a> `jitter?` | `boolean` | Add jitter to prevent thundering herd. **Default** `true` | [builder/queue.ts:521](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L521) |
|
|
629
|
-
| <a id="maxdelayms"></a> `maxDelayMs?` | `number` | Maximum delay in ms between retries. **Default** `30000` | [builder/queue.ts:509](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L509) |
|
|
630
|
-
| <a id="maxretries"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ. **Default** `3` | [builder/queue.ts:497](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L497) |
|
|
577
|
+
- Quorum queues (default): Do not support `exclusive`, `autoDelete`, or `maxPriority`
|
|
578
|
+
- Classic queues: Support all options including `exclusive`, `autoDelete`, and `maxPriority`
|
|
631
579
|
|
|
632
580
|
***
|
|
633
581
|
|
|
@@ -637,7 +585,7 @@ This simplified helper enforces the required configuration for TTL-backoff retry
|
|
|
637
585
|
type DirectExchangeDefinition<TName> = BaseExchangeDefinition<TName> & object;
|
|
638
586
|
```
|
|
639
587
|
|
|
640
|
-
Defined in: [types.ts:
|
|
588
|
+
Defined in: [types.ts:459](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L459)
|
|
641
589
|
|
|
642
590
|
A direct exchange definition.
|
|
643
591
|
|
|
@@ -648,7 +596,7 @@ This is ideal for point-to-point messaging where each message should go to speci
|
|
|
648
596
|
|
|
649
597
|
| Name | Type | Defined in |
|
|
650
598
|
| ------ | ------ | ------ |
|
|
651
|
-
| `type` | `"direct"` | [types.ts:
|
|
599
|
+
| `type` | `"direct"` | [types.ts:461](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L461) |
|
|
652
600
|
|
|
653
601
|
#### Type Parameters
|
|
654
602
|
|
|
@@ -659,8 +607,8 @@ This is ideal for point-to-point messaging where each message should go to speci
|
|
|
659
607
|
#### Example
|
|
660
608
|
|
|
661
609
|
```typescript
|
|
662
|
-
const tasksExchange: DirectExchangeDefinition = defineExchange('tasks',
|
|
663
|
-
|
|
610
|
+
const tasksExchange: DirectExchangeDefinition = defineExchange('tasks', {
|
|
611
|
+
type: 'direct',
|
|
664
612
|
});
|
|
665
613
|
```
|
|
666
614
|
|
|
@@ -669,10 +617,10 @@ const tasksExchange: DirectExchangeDefinition = defineExchange('tasks', 'direct'
|
|
|
669
617
|
### EventConsumerResult
|
|
670
618
|
|
|
671
619
|
```ts
|
|
672
|
-
type EventConsumerResult<TMessage, TExchange, TQueue,
|
|
620
|
+
type EventConsumerResult<TMessage, TExchange, TQueue, TExchangeBinding, TBridgeExchange> = object;
|
|
673
621
|
```
|
|
674
622
|
|
|
675
|
-
Defined in: [builder/event.ts:
|
|
623
|
+
Defined in: [builder/event.ts:54](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L54)
|
|
676
624
|
|
|
677
625
|
Result from defineEventConsumer.
|
|
678
626
|
|
|
@@ -686,8 +634,7 @@ will be automatically extracted.
|
|
|
686
634
|
| ------ | ------ | ------ |
|
|
687
635
|
| `TMessage` *extends* [`MessageDefinition`](#messagedefinition) | - | The message definition |
|
|
688
636
|
| `TExchange` *extends* [`ExchangeDefinition`](#exchangedefinition) | [`ExchangeDefinition`](#exchangedefinition) | - |
|
|
689
|
-
| `TQueue` *extends* [`
|
|
690
|
-
| `TDlxExchange` *extends* [`ExchangeDefinition`](#exchangedefinition) \| `undefined` | [`ExchangeDefinition`](#exchangedefinition) \| `undefined` | - |
|
|
637
|
+
| `TQueue` *extends* [`QueueEntry`](#queueentry) | [`QueueEntry`](#queueentry) | - |
|
|
691
638
|
| `TExchangeBinding` *extends* [`ExchangeBindingDefinition`](#exchangebindingdefinition) \| `undefined` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) \| `undefined` | - |
|
|
692
639
|
| `TBridgeExchange` *extends* [`ExchangeDefinition`](#exchangedefinition) \| `undefined` | [`ExchangeDefinition`](#exchangedefinition) \| `undefined` | - |
|
|
693
640
|
|
|
@@ -695,14 +642,13 @@ will be automatically extracted.
|
|
|
695
642
|
|
|
696
643
|
| Property | Type | Description | Defined in |
|
|
697
644
|
| ------ | ------ | ------ | ------ |
|
|
698
|
-
| <a id="__brand-4"></a> `__brand` | `"EventConsumerResult"` | Discriminator to identify this as an event consumer result | [builder/event.ts:
|
|
699
|
-
| <a id="binding-2"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | The binding connecting the queue to the exchange | [builder/event.ts:
|
|
700
|
-
| <a id="bridgeexchange-2"></a> `bridgeExchange` | `TBridgeExchange` | The bridge (local domain) exchange when bridging, if configured | [builder/event.ts:
|
|
701
|
-
| <a id="consumer-2"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition)<`TMessage`> | The consumer definition for processing messages | [builder/event.ts:
|
|
702
|
-
| <a id="
|
|
703
|
-
| <a id="
|
|
704
|
-
| <a id="
|
|
705
|
-
| <a id="queue-3"></a> `queue` | `TQueue` | The queue this consumer reads from | [builder/event.ts:75](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/event.ts#L75) |
|
|
645
|
+
| <a id="__brand-4"></a> `__brand` | `"EventConsumerResult"` | Discriminator to identify this as an event consumer result | [builder/event.ts:64](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L64) |
|
|
646
|
+
| <a id="binding-2"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | The binding connecting the queue to the exchange | [builder/event.ts:68](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L68) |
|
|
647
|
+
| <a id="bridgeexchange-2"></a> `bridgeExchange` | `TBridgeExchange` | The bridge (local domain) exchange when bridging, if configured | [builder/event.ts:76](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L76) |
|
|
648
|
+
| <a id="consumer-2"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition)<`TMessage`> | The consumer definition for processing messages | [builder/event.ts:66](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L66) |
|
|
649
|
+
| <a id="exchange-3"></a> `exchange` | `TExchange` | The source exchange this consumer subscribes to | [builder/event.ts:70](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L70) |
|
|
650
|
+
| <a id="exchangebinding-2"></a> `exchangeBinding` | `TExchangeBinding` | The exchange-to-exchange binding when bridging, if configured | [builder/event.ts:74](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L74) |
|
|
651
|
+
| <a id="queue-3"></a> `queue` | `TQueue` | The queue this consumer reads from | [builder/event.ts:72](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L72) |
|
|
706
652
|
|
|
707
653
|
***
|
|
708
654
|
|
|
@@ -712,7 +658,7 @@ will be automatically extracted.
|
|
|
712
658
|
type EventConsumerResultBase = object;
|
|
713
659
|
```
|
|
714
660
|
|
|
715
|
-
Defined in: [types.ts:
|
|
661
|
+
Defined in: [types.ts:1006](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1006)
|
|
716
662
|
|
|
717
663
|
Base type for event consumer result.
|
|
718
664
|
|
|
@@ -727,14 +673,13 @@ defineEventConsumer for creating event consumers
|
|
|
727
673
|
|
|
728
674
|
| Property | Type | Defined in |
|
|
729
675
|
| ------ | ------ | ------ |
|
|
730
|
-
| <a id="__brand-5"></a> `__brand` | `"EventConsumerResult"` | [types.ts:
|
|
731
|
-
| <a id="binding-3"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | [types.ts:
|
|
732
|
-
| <a id="bridgeexchange-3"></a> `bridgeExchange` | [`ExchangeDefinition`](#exchangedefinition) \| `undefined` | [types.ts:
|
|
733
|
-
| <a id="consumer-3"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition) | [types.ts:
|
|
734
|
-
| <a id="
|
|
735
|
-
| <a id="
|
|
736
|
-
| <a id="
|
|
737
|
-
| <a id="queue-4"></a> `queue` | [`QueueDefinition`](#queuedefinition) | [types.ts:954](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/types.ts#L954) |
|
|
676
|
+
| <a id="__brand-5"></a> `__brand` | `"EventConsumerResult"` | [types.ts:1007](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1007) |
|
|
677
|
+
| <a id="binding-3"></a> `binding` | [`QueueBindingDefinition`](#queuebindingdefinition) | [types.ts:1009](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1009) |
|
|
678
|
+
| <a id="bridgeexchange-3"></a> `bridgeExchange` | [`ExchangeDefinition`](#exchangedefinition) \| `undefined` | [types.ts:1013](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1013) |
|
|
679
|
+
| <a id="consumer-3"></a> `consumer` | [`ConsumerDefinition`](#consumerdefinition) | [types.ts:1008](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1008) |
|
|
680
|
+
| <a id="exchange-4"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:1010](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1010) |
|
|
681
|
+
| <a id="exchangebinding-3"></a> `exchangeBinding` | [`ExchangeBindingDefinition`](#exchangebindingdefinition) \| `undefined` | [types.ts:1012](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1012) |
|
|
682
|
+
| <a id="queue-4"></a> `queue` | [`QueueEntry`](#queueentry) | [types.ts:1011](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1011) |
|
|
738
683
|
|
|
739
684
|
***
|
|
740
685
|
|
|
@@ -744,7 +689,7 @@ defineEventConsumer for creating event consumers
|
|
|
744
689
|
type EventPublisherConfig<TMessage, TExchange, TRoutingKey> = object;
|
|
745
690
|
```
|
|
746
691
|
|
|
747
|
-
Defined in: [builder/event.ts:
|
|
692
|
+
Defined in: [builder/event.ts:28](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L28)
|
|
748
693
|
|
|
749
694
|
Configuration for an event publisher.
|
|
750
695
|
|
|
@@ -758,17 +703,17 @@ publishers broadcast events and consumers subscribe to receive them.
|
|
|
758
703
|
| ------ | ------ | ------ |
|
|
759
704
|
| `TMessage` *extends* [`MessageDefinition`](#messagedefinition) | - | The message definition |
|
|
760
705
|
| `TExchange` *extends* [`ExchangeDefinition`](#exchangedefinition) | - | The exchange definition |
|
|
761
|
-
| `TRoutingKey` *extends* `string` \| `undefined` | `undefined` | The routing key type (undefined for fanout) |
|
|
706
|
+
| `TRoutingKey` *extends* `string` \| `undefined` | `undefined` | The routing key type (undefined for fanout and headers exchanges) |
|
|
762
707
|
|
|
763
708
|
#### Properties
|
|
764
709
|
|
|
765
710
|
| Property | Type | Description | Defined in |
|
|
766
711
|
| ------ | ------ | ------ | ------ |
|
|
767
|
-
| <a id="__brand-6"></a> `__brand` | `"EventPublisherConfig"` | Discriminator to identify this as an event publisher config | [builder/event.ts:
|
|
768
|
-
| <a id="arguments-
|
|
769
|
-
| <a id="exchange-5"></a> `exchange` | `TExchange` | The exchange to publish to | [builder/event.ts:
|
|
770
|
-
| <a id="message-3"></a> `message` | `TMessage` | The message definition | [builder/event.ts:
|
|
771
|
-
| <a id="routingkey-3"></a> `routingKey` | `TRoutingKey` | The routing key for direct/topic exchanges | [builder/event.ts:
|
|
712
|
+
| <a id="__brand-6"></a> `__brand` | `"EventPublisherConfig"` | Discriminator to identify this as an event publisher config | [builder/event.ts:34](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L34) |
|
|
713
|
+
| <a id="arguments-1"></a> `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments | [builder/event.ts:42](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L42) |
|
|
714
|
+
| <a id="exchange-5"></a> `exchange` | `TExchange` | The exchange to publish to | [builder/event.ts:36](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L36) |
|
|
715
|
+
| <a id="message-3"></a> `message` | `TMessage` | The message definition | [builder/event.ts:38](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L38) |
|
|
716
|
+
| <a id="routingkey-3"></a> `routingKey` | `TRoutingKey` | The routing key for direct/topic exchanges | [builder/event.ts:40](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L40) |
|
|
772
717
|
|
|
773
718
|
***
|
|
774
719
|
|
|
@@ -778,7 +723,7 @@ publishers broadcast events and consumers subscribe to receive them.
|
|
|
778
723
|
type EventPublisherConfigBase = object;
|
|
779
724
|
```
|
|
780
725
|
|
|
781
|
-
Defined in: [types.ts:
|
|
726
|
+
Defined in: [types.ts:972](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L972)
|
|
782
727
|
|
|
783
728
|
Base type for event publisher configuration.
|
|
784
729
|
|
|
@@ -793,11 +738,11 @@ defineEventPublisher for creating event publishers
|
|
|
793
738
|
|
|
794
739
|
| Property | Type | Defined in |
|
|
795
740
|
| ------ | ------ | ------ |
|
|
796
|
-
| <a id="__brand-7"></a> `__brand` | `"EventPublisherConfig"` | [types.ts:
|
|
797
|
-
| <a id="arguments-
|
|
798
|
-
| <a id="exchange-6"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:
|
|
799
|
-
| <a id="message-4"></a> `message` | [`MessageDefinition`](#messagedefinition) | [types.ts:
|
|
800
|
-
| <a id="routingkey-4"></a> `routingKey` | `string` \| `undefined` | [types.ts:
|
|
741
|
+
| <a id="__brand-7"></a> `__brand` | `"EventPublisherConfig"` | [types.ts:973](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L973) |
|
|
742
|
+
| <a id="arguments-2"></a> `arguments?` | `Record`<`string`, `unknown`> | [types.ts:977](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L977) |
|
|
743
|
+
| <a id="exchange-6"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | [types.ts:974](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L974) |
|
|
744
|
+
| <a id="message-4"></a> `message` | [`MessageDefinition`](#messagedefinition) | [types.ts:975](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L975) |
|
|
745
|
+
| <a id="routingkey-4"></a> `routingKey` | `string` \| `undefined` | [types.ts:976](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L976) |
|
|
801
746
|
|
|
802
747
|
***
|
|
803
748
|
|
|
@@ -812,11 +757,12 @@ type ExchangeBindingDefinition = object &
|
|
|
812
757
|
}
|
|
813
758
|
| {
|
|
814
759
|
routingKey?: never;
|
|
815
|
-
source: FanoutExchangeDefinition
|
|
760
|
+
source: | FanoutExchangeDefinition
|
|
761
|
+
| HeadersExchangeDefinition;
|
|
816
762
|
};
|
|
817
763
|
```
|
|
818
764
|
|
|
819
|
-
Defined in: [types.ts:
|
|
765
|
+
Defined in: [types.ts:855](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L855)
|
|
820
766
|
|
|
821
767
|
Binding between two exchanges (exchange-to-exchange routing).
|
|
822
768
|
|
|
@@ -827,9 +773,9 @@ This allows for more complex routing topologies.
|
|
|
827
773
|
|
|
828
774
|
| Name | Type | Description | Defined in |
|
|
829
775
|
| ------ | ------ | ------ | ------ |
|
|
830
|
-
| `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for the binding. | [types.ts:
|
|
831
|
-
| `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:
|
|
832
|
-
| `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:
|
|
776
|
+
| `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for the binding. | [types.ts:865](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L865) |
|
|
777
|
+
| `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:860](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L860) |
|
|
778
|
+
| `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:857](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L857) |
|
|
833
779
|
|
|
834
780
|
#### Example
|
|
835
781
|
|
|
@@ -849,16 +795,17 @@ const binding: ExchangeBindingDefinition = {
|
|
|
849
795
|
|
|
850
796
|
```ts
|
|
851
797
|
type ExchangeDefinition<TName> =
|
|
852
|
-
|
|
|
798
|
+
| TopicExchangeDefinition<TName>
|
|
853
799
|
| DirectExchangeDefinition<TName>
|
|
854
|
-
|
|
|
800
|
+
| FanoutExchangeDefinition<TName>
|
|
801
|
+
| HeadersExchangeDefinition<TName>;
|
|
855
802
|
```
|
|
856
803
|
|
|
857
|
-
Defined in: [types.ts:
|
|
804
|
+
Defined in: [types.ts:505](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L505)
|
|
858
805
|
|
|
859
806
|
Union type of all exchange definitions.
|
|
860
807
|
|
|
861
|
-
Represents any type of AMQP exchange:
|
|
808
|
+
Represents any type of AMQP exchange: topic, direct, fanout, headers.
|
|
862
809
|
|
|
863
810
|
#### Type Parameters
|
|
864
811
|
|
|
@@ -874,7 +821,7 @@ Represents any type of AMQP exchange: fanout, direct, or topic.
|
|
|
874
821
|
type FanoutExchangeDefinition<TName> = BaseExchangeDefinition<TName> & object;
|
|
875
822
|
```
|
|
876
823
|
|
|
877
|
-
Defined in: [types.ts:
|
|
824
|
+
Defined in: [types.ts:477](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L477)
|
|
878
825
|
|
|
879
826
|
A fanout exchange definition.
|
|
880
827
|
|
|
@@ -885,7 +832,42 @@ This is the simplest exchange type for pub/sub messaging patterns.
|
|
|
885
832
|
|
|
886
833
|
| Name | Type | Defined in |
|
|
887
834
|
| ------ | ------ | ------ |
|
|
888
|
-
| `type` | `"fanout"` | [types.ts:
|
|
835
|
+
| `type` | `"fanout"` | [types.ts:479](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L479) |
|
|
836
|
+
|
|
837
|
+
#### Type Parameters
|
|
838
|
+
|
|
839
|
+
| Type Parameter | Default type |
|
|
840
|
+
| ------ | ------ |
|
|
841
|
+
| `TName` *extends* `string` | `string` |
|
|
842
|
+
|
|
843
|
+
#### Example
|
|
844
|
+
|
|
845
|
+
```typescript
|
|
846
|
+
const logsExchange: FanoutExchangeDefinition = defineExchange('logs', {
|
|
847
|
+
type: 'fanout',
|
|
848
|
+
});
|
|
849
|
+
```
|
|
850
|
+
|
|
851
|
+
***
|
|
852
|
+
|
|
853
|
+
### HeadersExchangeDefinition
|
|
854
|
+
|
|
855
|
+
```ts
|
|
856
|
+
type HeadersExchangeDefinition<TName> = BaseExchangeDefinition<TName> & object;
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
Defined in: [types.ts:495](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L495)
|
|
860
|
+
|
|
861
|
+
A headers exchange definition.
|
|
862
|
+
|
|
863
|
+
Headers exchanges route messages based on header values rather than routing keys.
|
|
864
|
+
This is useful for more complex routing scenarios where metadata is important.
|
|
865
|
+
|
|
866
|
+
#### Type Declaration
|
|
867
|
+
|
|
868
|
+
| Name | Type | Defined in |
|
|
869
|
+
| ------ | ------ | ------ |
|
|
870
|
+
| `type` | `"headers"` | [types.ts:497](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L497) |
|
|
889
871
|
|
|
890
872
|
#### Type Parameters
|
|
891
873
|
|
|
@@ -896,20 +878,51 @@ This is the simplest exchange type for pub/sub messaging patterns.
|
|
|
896
878
|
#### Example
|
|
897
879
|
|
|
898
880
|
```typescript
|
|
899
|
-
const
|
|
900
|
-
|
|
881
|
+
const routesExchange: HeadersExchangeDefinition = defineExchange('routes', {
|
|
882
|
+
type: 'headers',
|
|
901
883
|
});
|
|
902
884
|
```
|
|
903
885
|
|
|
904
886
|
***
|
|
905
887
|
|
|
888
|
+
### ImmediateRequeueRetryOptions
|
|
889
|
+
|
|
890
|
+
```ts
|
|
891
|
+
type ImmediateRequeueRetryOptions = object;
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
Defined in: [types.ts:88](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L88)
|
|
895
|
+
|
|
896
|
+
Immediate-Requeue retry options.
|
|
897
|
+
|
|
898
|
+
Failed messages are requeued immediately.
|
|
899
|
+
For quorum queues, messages are requeued with `nack(requeue=true)`, and the worker tracks delivery count via the native RabbitMQ `x-delivery-count` header.
|
|
900
|
+
For classic queues, messages are re-published on the same queue, and the worker tracks delivery count via a custom `x-retry-count` header.
|
|
901
|
+
When the count exceeds `maxRetries`, the message is automatically dead-lettered (if DLX is configured) or dropped.
|
|
902
|
+
|
|
903
|
+
**Benefits:** Simpler architecture, no wait queues needed, no head-of-queue blocking.
|
|
904
|
+
**Limitation:** Immediate retries only (no exponential backoff).
|
|
905
|
+
|
|
906
|
+
#### See
|
|
907
|
+
|
|
908
|
+
https://www.rabbitmq.com/docs/quorum-queues#poison-message-handling
|
|
909
|
+
|
|
910
|
+
#### Properties
|
|
911
|
+
|
|
912
|
+
| Property | Type | Description | Defined in |
|
|
913
|
+
| ------ | ------ | ------ | ------ |
|
|
914
|
+
| <a id="maxretries"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ. **Minimum** 1 - Must be a positive integer (1 or greater) **Default** `3` | [types.ts:98](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L98) |
|
|
915
|
+
| <a id="mode"></a> `mode` | `"immediate-requeue"` | Immediate-Requeue mode. | [types.ts:92](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L92) |
|
|
916
|
+
|
|
917
|
+
***
|
|
918
|
+
|
|
906
919
|
### InferConsumerNames
|
|
907
920
|
|
|
908
921
|
```ts
|
|
909
922
|
type InferConsumerNames<TContract> = TContract["consumers"] extends Record<string, unknown> ? keyof TContract["consumers"] : never;
|
|
910
923
|
```
|
|
911
924
|
|
|
912
|
-
Defined in: [types.ts:
|
|
925
|
+
Defined in: [types.ts:1609](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1609)
|
|
913
926
|
|
|
914
927
|
Extract consumer names from a contract.
|
|
915
928
|
|
|
@@ -941,7 +954,7 @@ type ConsumerNames = InferConsumerNames<typeof myContract>;
|
|
|
941
954
|
type InferPublisherNames<TContract> = TContract["publishers"] extends Record<string, unknown> ? keyof TContract["publishers"] : never;
|
|
942
955
|
```
|
|
943
956
|
|
|
944
|
-
Defined in: [types.ts:
|
|
957
|
+
Defined in: [types.ts:1591](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1591)
|
|
945
958
|
|
|
946
959
|
Extract publisher names from a contract.
|
|
947
960
|
|
|
@@ -967,13 +980,38 @@ type PublisherNames = InferPublisherNames<typeof myContract>;
|
|
|
967
980
|
|
|
968
981
|
***
|
|
969
982
|
|
|
983
|
+
### InferRpcNames
|
|
984
|
+
|
|
985
|
+
```ts
|
|
986
|
+
type InferRpcNames<TContract> = TContract["rpcs"] extends Record<string, RpcDefinition> ? keyof TContract["rpcs"] : never;
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
Defined in: [types.ts:1621](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1621)
|
|
990
|
+
|
|
991
|
+
Extract RPC names from a contract.
|
|
992
|
+
|
|
993
|
+
Each name in this union has a typed worker handler and a `client.call(name, ...)`
|
|
994
|
+
method. RPC names are disjoint from `InferConsumerNames` and `InferPublisherNames`.
|
|
995
|
+
|
|
996
|
+
#### Type Parameters
|
|
997
|
+
|
|
998
|
+
| Type Parameter | Description |
|
|
999
|
+
| ------ | ------ |
|
|
1000
|
+
| `TContract` *extends* [`ContractDefinition`](#contractdefinition) | The contract definition |
|
|
1001
|
+
|
|
1002
|
+
#### Returns
|
|
1003
|
+
|
|
1004
|
+
Union of RPC names, or never if no RPCs defined
|
|
1005
|
+
|
|
1006
|
+
***
|
|
1007
|
+
|
|
970
1008
|
### MatchingRoutingKey
|
|
971
1009
|
|
|
972
1010
|
```ts
|
|
973
1011
|
type MatchingRoutingKey<Pattern, Key> = RoutingKey<Key> extends never ? never : BindingPattern<Pattern> extends never ? never : MatchesPattern<Key, Pattern> extends true ? Key : never;
|
|
974
1012
|
```
|
|
975
1013
|
|
|
976
|
-
Defined in: [builder/routing-types.ts:114](https://github.com/btravers/amqp-contract/blob/
|
|
1014
|
+
Defined in: [builder/routing-types.ts:114](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/routing-types.ts#L114)
|
|
977
1015
|
|
|
978
1016
|
Validate that a routing key matches a binding pattern.
|
|
979
1017
|
|
|
@@ -1005,7 +1043,7 @@ type InvalidKey = MatchingRoutingKey<"order.*", "user.created">; // never
|
|
|
1005
1043
|
type MessageDefinition<TPayload, THeaders> = object;
|
|
1006
1044
|
```
|
|
1007
1045
|
|
|
1008
|
-
Defined in: [types.ts:
|
|
1046
|
+
Defined in: [types.ts:769](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L769)
|
|
1009
1047
|
|
|
1010
1048
|
Definition of a message with typed payload and optional headers.
|
|
1011
1049
|
|
|
@@ -1020,10 +1058,10 @@ Definition of a message with typed payload and optional headers.
|
|
|
1020
1058
|
|
|
1021
1059
|
| Property | Type | Description | Defined in |
|
|
1022
1060
|
| ------ | ------ | ------ | ------ |
|
|
1023
|
-
| <a id="description"></a> `description?` | `string` | Detailed description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:
|
|
1024
|
-
| <a id="headers"></a> `headers?` | `THeaders` | Optional headers schema for validating message metadata. Must be a Standard Schema v1 compatible schema. | [types.ts:
|
|
1025
|
-
| <a id="payload"></a> `payload` | `TPayload` | The payload schema for validating message content. Must be a Standard Schema v1 compatible schema (Zod, Valibot, ArkType, etc.). | [types.ts:
|
|
1026
|
-
| <a id="summary"></a> `summary?` | `string` | Brief description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:
|
|
1061
|
+
| <a id="description"></a> `description?` | `string` | Detailed description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:797](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L797) |
|
|
1062
|
+
| <a id="headers"></a> `headers?` | `THeaders` | Optional headers schema for validating message metadata. Must be a Standard Schema v1 compatible schema. | [types.ts:785](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L785) |
|
|
1063
|
+
| <a id="payload"></a> `payload` | `TPayload` | The payload schema for validating message content. Must be a Standard Schema v1 compatible schema (Zod, Valibot, ArkType, etc.). | [types.ts:779](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L779) |
|
|
1064
|
+
| <a id="summary"></a> `summary?` | `string` | Brief description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:791](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L791) |
|
|
1027
1065
|
|
|
1028
1066
|
***
|
|
1029
1067
|
|
|
@@ -1037,12 +1075,13 @@ type PublisherDefinition<TMessage> = object &
|
|
|
1037
1075
|
routingKey: string;
|
|
1038
1076
|
}
|
|
1039
1077
|
| {
|
|
1040
|
-
exchange: FanoutExchangeDefinition
|
|
1078
|
+
exchange: | FanoutExchangeDefinition
|
|
1079
|
+
| HeadersExchangeDefinition;
|
|
1041
1080
|
routingKey?: never;
|
|
1042
1081
|
};
|
|
1043
1082
|
```
|
|
1044
1083
|
|
|
1045
|
-
Defined in: [types.ts:
|
|
1084
|
+
Defined in: [types.ts:913](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L913)
|
|
1046
1085
|
|
|
1047
1086
|
Definition of a message publisher.
|
|
1048
1087
|
|
|
@@ -1056,7 +1095,7 @@ algorithm when calling the publish method.
|
|
|
1056
1095
|
|
|
1057
1096
|
| Name | Type | Description | Defined in |
|
|
1058
1097
|
| ------ | ------ | ------ | ------ |
|
|
1059
|
-
| `message` | `TMessage` | The message definition including the payload schema | [types.ts:
|
|
1098
|
+
| `message` | `TMessage` | The message definition including the payload schema | [types.ts:915](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L915) |
|
|
1060
1099
|
|
|
1061
1100
|
#### Type Parameters
|
|
1062
1101
|
|
|
@@ -1085,13 +1124,14 @@ type PublisherEntry =
|
|
|
1085
1124
|
| BridgedPublisherConfigBase;
|
|
1086
1125
|
```
|
|
1087
1126
|
|
|
1088
|
-
Defined in: [types.ts:
|
|
1127
|
+
Defined in: [types.ts:1149](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1149)
|
|
1089
1128
|
|
|
1090
1129
|
Publisher entry that can be passed to defineContract's publishers section.
|
|
1091
1130
|
|
|
1092
1131
|
Can be either:
|
|
1093
1132
|
- A plain PublisherDefinition from definePublisher
|
|
1094
1133
|
- An EventPublisherConfig from defineEventPublisher (auto-extracted to publisher)
|
|
1134
|
+
- An BridgedPublisherConfig from defineCommandPublisher (auto-extracted to publisher)
|
|
1095
1135
|
|
|
1096
1136
|
***
|
|
1097
1137
|
|
|
@@ -1105,26 +1145,27 @@ type QueueBindingDefinition = object &
|
|
|
1105
1145
|
routingKey: string;
|
|
1106
1146
|
}
|
|
1107
1147
|
| {
|
|
1108
|
-
exchange: FanoutExchangeDefinition
|
|
1148
|
+
exchange: | FanoutExchangeDefinition
|
|
1149
|
+
| HeadersExchangeDefinition;
|
|
1109
1150
|
routingKey?: never;
|
|
1110
1151
|
};
|
|
1111
1152
|
```
|
|
1112
1153
|
|
|
1113
|
-
Defined in: [types.ts:
|
|
1154
|
+
Defined in: [types.ts:807](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L807)
|
|
1114
1155
|
|
|
1115
1156
|
Binding between a queue and an exchange.
|
|
1116
1157
|
|
|
1117
1158
|
Defines how messages from an exchange should be routed to a queue.
|
|
1118
1159
|
For direct and topic exchanges, a routing key is required.
|
|
1119
|
-
For fanout exchanges, no routing key is needed
|
|
1160
|
+
For fanout and headers exchanges, no routing key is needed.
|
|
1120
1161
|
|
|
1121
1162
|
#### Type Declaration
|
|
1122
1163
|
|
|
1123
1164
|
| Name | Type | Description | Defined in |
|
|
1124
1165
|
| ------ | ------ | ------ | ------ |
|
|
1125
|
-
| `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for the binding. Can be used for advanced routing scenarios with the headers exchange type. | [types.ts:
|
|
1126
|
-
| `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:
|
|
1127
|
-
| `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:
|
|
1166
|
+
| `arguments?` | `Record`<`string`, `unknown`> | Additional AMQP arguments for the binding. Can be used for advanced routing scenarios with the headers exchange type. | [types.ts:818](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L818) |
|
|
1167
|
+
| `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:812](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L812) |
|
|
1168
|
+
| `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:809](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L809) |
|
|
1128
1169
|
|
|
1129
1170
|
***
|
|
1130
1171
|
|
|
@@ -1136,7 +1177,7 @@ type QueueDefinition<TName> =
|
|
|
1136
1177
|
| ClassicQueueDefinition<TName>;
|
|
1137
1178
|
```
|
|
1138
1179
|
|
|
1139
|
-
Defined in: [types.ts:
|
|
1180
|
+
Defined in: [types.ts:646](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L646)
|
|
1140
1181
|
|
|
1141
1182
|
Definition of an AMQP queue.
|
|
1142
1183
|
|
|
@@ -1162,7 +1203,7 @@ type QueueEntry<TName> =
|
|
|
1162
1203
|
| QueueWithTtlBackoffInfrastructure<TName>;
|
|
1163
1204
|
```
|
|
1164
1205
|
|
|
1165
|
-
Defined in: [types.ts:
|
|
1206
|
+
Defined in: [types.ts:749](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L749)
|
|
1166
1207
|
|
|
1167
1208
|
A queue entry that can be passed to `defineContract`.
|
|
1168
1209
|
|
|
@@ -1182,7 +1223,7 @@ Can be either a plain queue definition or a queue with TTL-backoff infrastructur
|
|
|
1182
1223
|
type QueueType = "quorum" | "classic";
|
|
1183
1224
|
```
|
|
1184
1225
|
|
|
1185
|
-
Defined in: [types.ts:
|
|
1226
|
+
Defined in: [types.ts:227](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L227)
|
|
1186
1227
|
|
|
1187
1228
|
Supported queue types in RabbitMQ.
|
|
1188
1229
|
|
|
@@ -1191,8 +1232,7 @@ Supported queue types in RabbitMQ.
|
|
|
1191
1232
|
- `classic`: Classic queues - The traditional RabbitMQ queue type. Use only when you need
|
|
1192
1233
|
specific features not supported by quorum queues (e.g., non-durable queues, priority queues).
|
|
1193
1234
|
|
|
1194
|
-
Note: Quorum queues
|
|
1195
|
-
When using quorum queues, `durable` is automatically set to `true`.
|
|
1235
|
+
Note: Quorum queues only support durable queues, and do not support exclusive, auto-deleting, or priority queues.
|
|
1196
1236
|
|
|
1197
1237
|
#### See
|
|
1198
1238
|
|
|
@@ -1221,31 +1261,29 @@ const tempQueue = defineQueue('temp-queue', {
|
|
|
1221
1261
|
type QueueWithTtlBackoffInfrastructure<TName> = object;
|
|
1222
1262
|
```
|
|
1223
1263
|
|
|
1224
|
-
Defined in: [types.ts:
|
|
1264
|
+
Defined in: [types.ts:706](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L706)
|
|
1225
1265
|
|
|
1226
1266
|
A queue with automatically generated TTL-backoff retry infrastructure.
|
|
1227
1267
|
|
|
1228
|
-
This type is returned by `defineQueue` when TTL-backoff retry is configured
|
|
1229
|
-
|
|
1230
|
-
|
|
1268
|
+
This type is returned by `defineQueue` when TTL-backoff retry is configured.
|
|
1269
|
+
When passed to `defineContract`, the wait queue, exchanges, and bindings are
|
|
1270
|
+
automatically added to the contract.
|
|
1231
1271
|
|
|
1232
1272
|
#### Example
|
|
1233
1273
|
|
|
1234
1274
|
```typescript
|
|
1235
|
-
const
|
|
1236
|
-
const exchange = defineExchange('orders', 'topic', { durable: true });
|
|
1275
|
+
const exchange = defineExchange('orders');
|
|
1237
1276
|
const queue = defineQueue('order-processing', {
|
|
1238
|
-
deadLetter: { exchange: dlx },
|
|
1239
1277
|
retry: { mode: 'ttl-backoff', maxRetries: 5 },
|
|
1240
1278
|
});
|
|
1241
1279
|
// queue is QueueWithTtlBackoffInfrastructure
|
|
1242
1280
|
const message = defineMessage(z.object({ orderId: z.string() }));
|
|
1243
1281
|
const orderCreated = defineEventPublisher(exchange, message, { routingKey: 'order.created' });
|
|
1244
1282
|
|
|
1245
|
-
// Wait queue,
|
|
1283
|
+
// Wait queue, exchanges, and bindings are automatically extracted
|
|
1246
1284
|
const contract = defineContract({
|
|
1247
1285
|
publishers: { orderCreated },
|
|
1248
|
-
consumers: { processOrder: defineEventConsumer(orderCreated,
|
|
1286
|
+
consumers: { processOrder: defineEventConsumer(orderCreated, queue) },
|
|
1249
1287
|
});
|
|
1250
1288
|
```
|
|
1251
1289
|
|
|
@@ -1259,41 +1297,12 @@ const contract = defineContract({
|
|
|
1259
1297
|
|
|
1260
1298
|
| Property | Type | Description | Defined in |
|
|
1261
1299
|
| ------ | ------ | ------ | ------ |
|
|
1262
|
-
| <a id="
|
|
1263
|
-
| <a id="
|
|
1264
|
-
| <a id="
|
|
1265
|
-
| <a id="
|
|
1266
|
-
| <a id="
|
|
1267
|
-
|
|
1268
|
-
***
|
|
1269
|
-
|
|
1270
|
-
### QuorumNativeRetryOptions
|
|
1271
|
-
|
|
1272
|
-
```ts
|
|
1273
|
-
type QuorumNativeRetryOptions = object;
|
|
1274
|
-
```
|
|
1275
|
-
|
|
1276
|
-
Defined in: [types.ts:72](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/types.ts#L72)
|
|
1277
|
-
|
|
1278
|
-
Quorum-Native retry options using RabbitMQ's native delivery limit feature.
|
|
1279
|
-
|
|
1280
|
-
Uses quorum queue's `x-delivery-limit` feature. Messages are requeued immediately
|
|
1281
|
-
with `nack(requeue=true)`, and RabbitMQ tracks delivery count via `x-delivery-count`
|
|
1282
|
-
header. When the count exceeds the queue's `deliveryLimit`, the message is
|
|
1283
|
-
automatically dead-lettered.
|
|
1284
|
-
|
|
1285
|
-
**Benefits:** Simpler architecture, no wait queues needed, no head-of-queue blocking.
|
|
1286
|
-
**Limitation:** Immediate retries only (no exponential backoff).
|
|
1287
|
-
|
|
1288
|
-
#### See
|
|
1289
|
-
|
|
1290
|
-
https://www.rabbitmq.com/docs/quorum-queues#poison-message-handling
|
|
1291
|
-
|
|
1292
|
-
#### Properties
|
|
1293
|
-
|
|
1294
|
-
| Property | Type | Description | Defined in |
|
|
1295
|
-
| ------ | ------ | ------ | ------ |
|
|
1296
|
-
| <a id="mode"></a> `mode` | `"quorum-native"` | Quorum-Native mode uses RabbitMQ's native delivery limit feature. Requires the queue to be a quorum queue with `deliveryLimit` configured. | [types.ts:77](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/types.ts#L77) |
|
|
1300
|
+
| <a id="queue-5"></a> `queue` | [`QueueDefinition`](#queuedefinition)<`TName`> | The main queue definition. | [types.ts:716](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L716) |
|
|
1301
|
+
| <a id="retryexchange"></a> `retryExchange` | [`HeadersExchangeDefinition`](#headersexchangedefinition) | Retry exchange used to route messages to retry back to the main queue. | [types.ts:731](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L731) |
|
|
1302
|
+
| <a id="retryqueuebinding"></a> `retryQueueBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes messages to retry back to the main queue. | [types.ts:741](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L741) |
|
|
1303
|
+
| <a id="waitexchange"></a> `waitExchange` | [`HeadersExchangeDefinition`](#headersexchangedefinition) | Wait exchange used to route failed messages to the wait queue. | [types.ts:726](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L726) |
|
|
1304
|
+
| <a id="waitqueue"></a> `waitQueue` | [`QueueDefinition`](#queuedefinition) | The wait queue for holding messages during backoff delay. | [types.ts:721](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L721) |
|
|
1305
|
+
| <a id="waitqueuebinding"></a> `waitQueueBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes failed messages to the wait queue. | [types.ts:736](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L736) |
|
|
1297
1306
|
|
|
1298
1307
|
***
|
|
1299
1308
|
|
|
@@ -1303,22 +1312,21 @@ https://www.rabbitmq.com/docs/quorum-queues#poison-message-handling
|
|
|
1303
1312
|
type QuorumQueueDefinition<TName> = BaseQueueDefinition<TName> & object;
|
|
1304
1313
|
```
|
|
1305
1314
|
|
|
1306
|
-
Defined in: [types.ts:
|
|
1315
|
+
Defined in: [types.ts:572](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L572)
|
|
1307
1316
|
|
|
1308
1317
|
Definition of a quorum queue.
|
|
1309
1318
|
|
|
1310
1319
|
Quorum queues provide better durability and high-availability using the Raft consensus algorithm.
|
|
1311
|
-
They support native retry handling via `deliveryLimit` and both TTL-backoff and quorum-native retry modes.
|
|
1312
1320
|
|
|
1313
1321
|
#### Type Declaration
|
|
1314
1322
|
|
|
1315
1323
|
| Name | Type | Description | Defined in |
|
|
1316
1324
|
| ------ | ------ | ------ | ------ |
|
|
1317
|
-
| `
|
|
1318
|
-
| `
|
|
1319
|
-
| `
|
|
1320
|
-
| `
|
|
1321
|
-
| `type` | `"quorum"` | Queue type discriminator: quorum queue. | [types.ts:
|
|
1325
|
+
| `autoDelete?` | `never` | Quorum queues do not support auto-delete mode. Use type: 'classic' if you need auto-deleting queues. | [types.ts:593](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L593) |
|
|
1326
|
+
| `durable` | `true` | Quorum queues only support durable queues. | [types.ts:581](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L581) |
|
|
1327
|
+
| `exclusive?` | `never` | Quorum queues do not support exclusive mode. Use type: 'classic' if you need exclusive queues. | [types.ts:587](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L587) |
|
|
1328
|
+
| `maxPriority?` | `never` | Quorum queues do not support priority queues. Use type: 'classic' if you need priority queues. | [types.ts:599](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L599) |
|
|
1329
|
+
| `type` | `"quorum"` | Queue type discriminator: quorum queue. | [types.ts:576](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L576) |
|
|
1322
1330
|
|
|
1323
1331
|
#### Type Parameters
|
|
1324
1332
|
|
|
@@ -1334,28 +1342,30 @@ They support native retry handling via `deliveryLimit` and both TTL-backoff and
|
|
|
1334
1342
|
type QuorumQueueOptions = BaseQueueOptions & object;
|
|
1335
1343
|
```
|
|
1336
1344
|
|
|
1337
|
-
Defined in: [types.ts:
|
|
1345
|
+
Defined in: [types.ts:295](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L295)
|
|
1338
1346
|
|
|
1339
1347
|
Options for creating a quorum queue.
|
|
1340
1348
|
|
|
1341
1349
|
Quorum queues do not support:
|
|
1342
|
-
- `exclusive` - Use classic queues for
|
|
1350
|
+
- `exclusive` - Use classic queues for connection-scoped queues
|
|
1351
|
+
- `autoDelete` - Use classic queues for auto-deleting queues when consumers disconnect
|
|
1343
1352
|
- `maxPriority` - Use classic queues for priority queues
|
|
1353
|
+
- `durable: false` - Use classic queues for non-durable queues
|
|
1344
1354
|
|
|
1345
|
-
Quorum queues provide native retry support
|
|
1355
|
+
Quorum queues provide native retry support for immediate-requeue retry mode:
|
|
1346
1356
|
- RabbitMQ tracks delivery count automatically via `x-delivery-count` header
|
|
1347
|
-
- When the limit is exceeded, messages are dead-lettered (if DLX is configured)
|
|
1357
|
+
- When the limit is exceeded, messages are dead-lettered (if DLX is configured) or dropped
|
|
1348
1358
|
- This is simpler than TTL-based retry and avoids head-of-queue blocking issues
|
|
1349
1359
|
|
|
1350
1360
|
#### Type Declaration
|
|
1351
1361
|
|
|
1352
1362
|
| Name | Type | Description | Defined in |
|
|
1353
1363
|
| ------ | ------ | ------ | ------ |
|
|
1354
|
-
| `
|
|
1355
|
-
| `
|
|
1356
|
-
| `
|
|
1357
|
-
| `
|
|
1358
|
-
| `type?` | `"quorum"` | Queue type: quorum (default, recommended) | [types.ts:
|
|
1364
|
+
| `autoDelete?` | `never` | Quorum queues do not support auto-delete mode. Use type: 'classic' if you need auto-deleting queues. | [types.ts:316](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L316) |
|
|
1365
|
+
| `durable?` | `true` | Quorum queues only support durable queues. | [types.ts:304](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L304) |
|
|
1366
|
+
| `exclusive?` | `never` | Quorum queues do not support exclusive mode. Use type: 'classic' if you need exclusive queues. | [types.ts:310](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L310) |
|
|
1367
|
+
| `maxPriority?` | `never` | Quorum queues do not support priority queues. Use type: 'classic' if you need priority queues. | [types.ts:322](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L322) |
|
|
1368
|
+
| `type?` | `"quorum"` | Queue type: quorum (default, recommended) | [types.ts:299](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L299) |
|
|
1359
1369
|
|
|
1360
1370
|
#### Example
|
|
1361
1371
|
|
|
@@ -1363,7 +1373,7 @@ Quorum queues provide native retry support via `deliveryLimit`:
|
|
|
1363
1373
|
const orderQueue = defineQueue('orders', {
|
|
1364
1374
|
type: 'quorum',
|
|
1365
1375
|
deadLetter: { exchange: dlx },
|
|
1366
|
-
|
|
1376
|
+
retry: { mode: 'immediate-requeue', maxRetries: 3 } // Message dead-lettered after 3 retry attempts
|
|
1367
1377
|
});
|
|
1368
1378
|
```
|
|
1369
1379
|
|
|
@@ -1373,17 +1383,22 @@ const orderQueue = defineQueue('orders', {
|
|
|
1373
1383
|
|
|
1374
1384
|
```ts
|
|
1375
1385
|
type ResolvedRetryOptions =
|
|
1376
|
-
|
|
|
1377
|
-
|
|
|
1386
|
+
| NoneRetryOptions
|
|
1387
|
+
| ResolvedImmediateRequeueRetryOptions
|
|
1388
|
+
| ResolvedTtlBackoffRetryOptions;
|
|
1378
1389
|
```
|
|
1379
1390
|
|
|
1380
|
-
Defined in: [types.ts:
|
|
1391
|
+
Defined in: [types.ts:166](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L166)
|
|
1381
1392
|
|
|
1382
1393
|
Resolved retry configuration stored in queue definitions.
|
|
1383
1394
|
|
|
1384
1395
|
This is a discriminated union based on the `mode` field:
|
|
1385
|
-
- `
|
|
1386
|
-
- `
|
|
1396
|
+
- `none`: No retry attempts are made; failed messages are handled by DLQ/reject
|
|
1397
|
+
- `immediate-requeue`: Has all immediate-requeue retry options with default applied
|
|
1398
|
+
- `ttl-backoff`: Has all TTL-backoff retry options with defaults applied
|
|
1399
|
+
|
|
1400
|
+
When using `ttl-backoff` mode, the core package will automatically create
|
|
1401
|
+
a wait queue and the necessary exchanges and bindings.
|
|
1387
1402
|
|
|
1388
1403
|
***
|
|
1389
1404
|
|
|
@@ -1393,7 +1408,7 @@ This is a discriminated union based on the `mode` field:
|
|
|
1393
1408
|
type RoutingKey<S> = S extends "" ? never : S extends `${string}*${string}` | `${string}#${string}` ? never : S;
|
|
1394
1409
|
```
|
|
1395
1410
|
|
|
1396
|
-
Defined in: [builder/routing-types.ts:25](https://github.com/btravers/amqp-contract/blob/
|
|
1411
|
+
Defined in: [builder/routing-types.ts:25](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/routing-types.ts#L25)
|
|
1397
1412
|
|
|
1398
1413
|
Type-safe routing key that validates basic format.
|
|
1399
1414
|
|
|
@@ -1421,13 +1436,51 @@ type Invalid2 = RoutingKey<"">; // never (empty string)
|
|
|
1421
1436
|
|
|
1422
1437
|
***
|
|
1423
1438
|
|
|
1439
|
+
### RpcDefinition
|
|
1440
|
+
|
|
1441
|
+
```ts
|
|
1442
|
+
type RpcDefinition<TRequestMessage, TResponseMessage, TQueue> = object;
|
|
1443
|
+
```
|
|
1444
|
+
|
|
1445
|
+
Defined in: [types.ts:1047](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1047)
|
|
1446
|
+
|
|
1447
|
+
Definition of an RPC operation: a request/response pair flowing over a
|
|
1448
|
+
request queue with replies routed back via direct reply-to.
|
|
1449
|
+
|
|
1450
|
+
An RPC is bidirectional on both ends — the server consumes requests and
|
|
1451
|
+
publishes responses; the client publishes requests and consumes responses —
|
|
1452
|
+
so it has its own slot in the contract (`rpcs`) rather than being shoehorned
|
|
1453
|
+
into `consumers` or `publishers`.
|
|
1454
|
+
|
|
1455
|
+
#### See
|
|
1456
|
+
|
|
1457
|
+
defineRpc for creating RPC definitions
|
|
1458
|
+
|
|
1459
|
+
#### Type Parameters
|
|
1460
|
+
|
|
1461
|
+
| Type Parameter | Default type | Description |
|
|
1462
|
+
| ------ | ------ | ------ |
|
|
1463
|
+
| `TRequestMessage` *extends* [`MessageDefinition`](#messagedefinition) | [`MessageDefinition`](#messagedefinition) | The request message definition |
|
|
1464
|
+
| `TResponseMessage` *extends* [`MessageDefinition`](#messagedefinition) | [`MessageDefinition`](#messagedefinition) | The response message definition |
|
|
1465
|
+
| `TQueue` *extends* [`QueueEntry`](#queueentry) | [`QueueEntry`](#queueentry) | The request queue entry |
|
|
1466
|
+
|
|
1467
|
+
#### Properties
|
|
1468
|
+
|
|
1469
|
+
| Property | Type | Description | Defined in |
|
|
1470
|
+
| ------ | ------ | ------ | ------ |
|
|
1471
|
+
| <a id="queue-6"></a> `queue` | `TQueue` | The queue that receives RPC requests. Replies are routed back via direct reply-to. | [types.ts:1053](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1053) |
|
|
1472
|
+
| <a id="request"></a> `request` | `TRequestMessage` | Schema for the request payload (validated on both publish and consume). | [types.ts:1055](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1055) |
|
|
1473
|
+
| <a id="response"></a> `response` | `TResponseMessage` | Schema for the response payload (validated on both worker reply and client receive). | [types.ts:1057](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L1057) |
|
|
1474
|
+
|
|
1475
|
+
***
|
|
1476
|
+
|
|
1424
1477
|
### TopicExchangeDefinition
|
|
1425
1478
|
|
|
1426
1479
|
```ts
|
|
1427
1480
|
type TopicExchangeDefinition<TName> = BaseExchangeDefinition<TName> & object;
|
|
1428
1481
|
```
|
|
1429
1482
|
|
|
1430
|
-
Defined in: [types.ts:
|
|
1483
|
+
Defined in: [types.ts:441](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L441)
|
|
1431
1484
|
|
|
1432
1485
|
A topic exchange definition.
|
|
1433
1486
|
|
|
@@ -1441,7 +1494,7 @@ Words are separated by dots (e.g., `order.created.high-value`).
|
|
|
1441
1494
|
|
|
1442
1495
|
| Name | Type | Defined in |
|
|
1443
1496
|
| ------ | ------ | ------ |
|
|
1444
|
-
| `type` | `"topic"` | [types.ts:
|
|
1497
|
+
| `type` | `"topic"` | [types.ts:443](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L443) |
|
|
1445
1498
|
|
|
1446
1499
|
#### Type Parameters
|
|
1447
1500
|
|
|
@@ -1452,43 +1505,21 @@ Words are separated by dots (e.g., `order.created.high-value`).
|
|
|
1452
1505
|
#### Example
|
|
1453
1506
|
|
|
1454
1507
|
```typescript
|
|
1455
|
-
const ordersExchange: TopicExchangeDefinition = defineExchange('orders',
|
|
1456
|
-
|
|
1508
|
+
const ordersExchange: TopicExchangeDefinition = defineExchange('orders', {
|
|
1509
|
+
type: 'topic', // This is the default type, so it can be omitted
|
|
1457
1510
|
});
|
|
1458
1511
|
// Can be bound with patterns like 'order.*' or 'order.#'
|
|
1459
1512
|
```
|
|
1460
1513
|
|
|
1461
1514
|
***
|
|
1462
1515
|
|
|
1463
|
-
### TtlBackoffRetryInfrastructure
|
|
1464
|
-
|
|
1465
|
-
```ts
|
|
1466
|
-
type TtlBackoffRetryInfrastructure = object;
|
|
1467
|
-
```
|
|
1468
|
-
|
|
1469
|
-
Defined in: [builder/ttl-backoff.ts:9](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/ttl-backoff.ts#L9)
|
|
1470
|
-
|
|
1471
|
-
Result type for TTL-backoff retry infrastructure builder.
|
|
1472
|
-
|
|
1473
|
-
Contains the wait queue and bindings needed for TTL-backoff retry.
|
|
1474
|
-
|
|
1475
|
-
#### Properties
|
|
1476
|
-
|
|
1477
|
-
| Property | Type | Description | Defined in |
|
|
1478
|
-
| ------ | ------ | ------ | ------ |
|
|
1479
|
-
| <a id="mainqueueretrybinding-1"></a> `mainQueueRetryBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes retried messages back to the main queue. | [builder/ttl-backoff.ts:22](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/ttl-backoff.ts#L22) |
|
|
1480
|
-
| <a id="waitqueue-1"></a> `waitQueue` | [`QueueDefinition`](#queuedefinition) | The wait queue for holding messages during backoff delay. This is a classic queue with a dead letter exchange pointing back to the main queue. | [builder/ttl-backoff.ts:14](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/ttl-backoff.ts#L14) |
|
|
1481
|
-
| <a id="waitqueuebinding-1"></a> `waitQueueBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes failed messages to the wait queue. | [builder/ttl-backoff.ts:18](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/ttl-backoff.ts#L18) |
|
|
1482
|
-
|
|
1483
|
-
***
|
|
1484
|
-
|
|
1485
1516
|
### TtlBackoffRetryOptions
|
|
1486
1517
|
|
|
1487
1518
|
```ts
|
|
1488
1519
|
type TtlBackoffRetryOptions = object;
|
|
1489
1520
|
```
|
|
1490
1521
|
|
|
1491
|
-
Defined in: [types.ts:27](https://github.com/btravers/amqp-contract/blob/
|
|
1522
|
+
Defined in: [types.ts:27](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L27)
|
|
1492
1523
|
|
|
1493
1524
|
TTL-Backoff retry options for exponential backoff with configurable delays.
|
|
1494
1525
|
|
|
@@ -1502,12 +1533,15 @@ per-message TTL, then dead-lettered back to the main queue after the TTL expires
|
|
|
1502
1533
|
|
|
1503
1534
|
| Property | Type | Description | Defined in |
|
|
1504
1535
|
| ------ | ------ | ------ | ------ |
|
|
1505
|
-
| <a id="backoffmultiplier
|
|
1506
|
-
| <a id="initialdelayms
|
|
1507
|
-
| <a id="jitter
|
|
1508
|
-
| <a id="maxdelayms
|
|
1509
|
-
| <a id="maxretries-1"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ. **Default** `3` | [types.ts:
|
|
1510
|
-
| <a id="mode-1"></a> `mode` | `"ttl-backoff"` | TTL-Backoff mode uses wait queues with per-message TTL for exponential backoff. | [types.ts:31](https://github.com/btravers/amqp-contract/blob/
|
|
1536
|
+
| <a id="backoffmultiplier"></a> `backoffMultiplier?` | `number` | Exponential backoff multiplier. **Default** `2` | [types.ts:52](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L52) |
|
|
1537
|
+
| <a id="initialdelayms"></a> `initialDelayMs?` | `number` | Initial delay in ms before first retry. **Default** `1000` | [types.ts:42](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L42) |
|
|
1538
|
+
| <a id="jitter"></a> `jitter?` | `boolean` | Add jitter to prevent thundering herd. **Default** `true` | [types.ts:57](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L57) |
|
|
1539
|
+
| <a id="maxdelayms"></a> `maxDelayMs?` | `number` | Maximum delay in ms between retries. **Default** `30000` | [types.ts:47](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L47) |
|
|
1540
|
+
| <a id="maxretries-1"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ. **Minimum** 1 - Must be a positive integer (1 or greater) **Default** `3` | [types.ts:37](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L37) |
|
|
1541
|
+
| <a id="mode-1"></a> `mode` | `"ttl-backoff"` | TTL-Backoff mode uses wait queues with per-message TTL for exponential backoff. | [types.ts:31](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L31) |
|
|
1542
|
+
| <a id="retryexchangename"></a> `retryExchangeName?` | `string` | Name of the retry exchange. **Default** `'retry-exchange'` | [types.ts:72](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L72) |
|
|
1543
|
+
| <a id="waitexchangename"></a> `waitExchangeName?` | `string` | Name of the wait exchange. **Default** `'wait-exchange'` | [types.ts:67](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L67) |
|
|
1544
|
+
| <a id="waitqueuename"></a> `waitQueueName?` | `string` | Name of the wait queue. **Default** `'{queueName}-wait'` | [types.ts:62](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/types.ts#L62) |
|
|
1511
1545
|
|
|
1512
1546
|
## Functions
|
|
1513
1547
|
|
|
@@ -1520,7 +1554,7 @@ function defineConsumer<TMessage>(
|
|
|
1520
1554
|
options?): ConsumerDefinition<TMessage>;
|
|
1521
1555
|
```
|
|
1522
1556
|
|
|
1523
|
-
Defined in: [builder/consumer.ts:
|
|
1557
|
+
Defined in: [builder/consumer.ts:120](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/consumer.ts#L120)
|
|
1524
1558
|
|
|
1525
1559
|
Define a message consumer.
|
|
1526
1560
|
|
|
@@ -1568,7 +1602,7 @@ A consumer definition with inferred message types
|
|
|
1568
1602
|
```typescript
|
|
1569
1603
|
import { z } from 'zod';
|
|
1570
1604
|
|
|
1571
|
-
const orderQueue = defineQueue('order-processing'
|
|
1605
|
+
const orderQueue = defineQueue('order-processing');
|
|
1572
1606
|
const orderMessage = defineMessage(
|
|
1573
1607
|
z.object({
|
|
1574
1608
|
orderId: z.string().uuid(),
|
|
@@ -1605,7 +1639,7 @@ const processOrderConsumer = defineConsumer(orderQueue, orderMessage);
|
|
|
1605
1639
|
function defineContract<TContract>(definition): ContractOutput<TContract>;
|
|
1606
1640
|
```
|
|
1607
1641
|
|
|
1608
|
-
Defined in: [builder/contract.ts:
|
|
1642
|
+
Defined in: [builder/contract.ts:83](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/contract.ts#L83)
|
|
1609
1643
|
|
|
1610
1644
|
Define an AMQP contract.
|
|
1611
1645
|
|
|
@@ -1649,12 +1683,11 @@ import {
|
|
|
1649
1683
|
import { z } from 'zod';
|
|
1650
1684
|
|
|
1651
1685
|
// Define resources
|
|
1652
|
-
const ordersExchange = defineExchange('orders'
|
|
1653
|
-
const dlx = defineExchange('orders-dlx',
|
|
1686
|
+
const ordersExchange = defineExchange('orders');
|
|
1687
|
+
const dlx = defineExchange('orders-dlx', { type: 'direct' });
|
|
1654
1688
|
const orderQueue = defineQueue('order-processing', {
|
|
1655
1689
|
deadLetter: { exchange: dlx },
|
|
1656
|
-
retry: { mode: '
|
|
1657
|
-
deliveryLimit: 3,
|
|
1690
|
+
retry: { mode: 'immediate-requeue', maxRetries: 3 },
|
|
1658
1691
|
});
|
|
1659
1692
|
const orderMessage = defineMessage(
|
|
1660
1693
|
z.object({
|
|
@@ -1694,7 +1727,7 @@ export const contract = defineContract({
|
|
|
1694
1727
|
function defineMessage<TPayload, THeaders>(payload, options?): MessageDefinition<TPayload, THeaders>;
|
|
1695
1728
|
```
|
|
1696
1729
|
|
|
1697
|
-
Defined in: [builder/message.ts:39](https://github.com/btravers/amqp-contract/blob/
|
|
1730
|
+
Defined in: [builder/message.ts:39](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/message.ts#L39)
|
|
1698
1731
|
|
|
1699
1732
|
Define a message definition with payload and optional headers/metadata.
|
|
1700
1733
|
|
|
@@ -1754,10 +1787,10 @@ const orderMessage = defineMessage(
|
|
|
1754
1787
|
#### Call Signature
|
|
1755
1788
|
|
|
1756
1789
|
```ts
|
|
1757
|
-
function defineQueue<TName, TDlx>(name, options):
|
|
1790
|
+
function defineQueue<TName, TDlx>(name, options): QueueEntryWithDeadLetterExchange<TName, TDlx>;
|
|
1758
1791
|
```
|
|
1759
1792
|
|
|
1760
|
-
Defined in: [builder/queue.ts:
|
|
1793
|
+
Defined in: [builder/queue.ts:113](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/queue.ts#L113)
|
|
1761
1794
|
|
|
1762
1795
|
Define an AMQP queue.
|
|
1763
1796
|
|
|
@@ -1780,11 +1813,11 @@ or priority queues.
|
|
|
1780
1813
|
| Parameter | Type | Description |
|
|
1781
1814
|
| ------ | ------ | ------ |
|
|
1782
1815
|
| `name` | `TName` | The name of the queue |
|
|
1783
|
-
| `options` |
|
|
1816
|
+
| `options` | `DefineQueueOptionsWithDeadLetterExchange`<`TDlx`> | Optional queue configuration |
|
|
1784
1817
|
|
|
1785
1818
|
##### Returns
|
|
1786
1819
|
|
|
1787
|
-
|
|
1820
|
+
`QueueEntryWithDeadLetterExchange`<`TName`, `TDlx`>
|
|
1788
1821
|
|
|
1789
1822
|
A queue definition
|
|
1790
1823
|
|
|
@@ -1795,7 +1828,7 @@ A queue definition
|
|
|
1795
1828
|
const orderQueue = defineQueue('order-processing');
|
|
1796
1829
|
|
|
1797
1830
|
// Explicit quorum queue with dead letter exchange
|
|
1798
|
-
const dlx = defineExchange('orders-dlx'
|
|
1831
|
+
const dlx = defineExchange('orders-dlx');
|
|
1799
1832
|
const orderQueueWithDLX = defineQueue('order-processing', {
|
|
1800
1833
|
type: 'quorum',
|
|
1801
1834
|
deadLetter: {
|
|
@@ -1817,12 +1850,11 @@ const tempQueue = defineQueue('temp-queue', {
|
|
|
1817
1850
|
// Priority queue (requires classic type)
|
|
1818
1851
|
const taskQueue = defineQueue('urgent-tasks', {
|
|
1819
1852
|
type: 'classic',
|
|
1820
|
-
durable: true,
|
|
1821
1853
|
maxPriority: 10,
|
|
1822
1854
|
});
|
|
1823
1855
|
|
|
1824
1856
|
// Queue with TTL-backoff retry (returns infrastructure automatically)
|
|
1825
|
-
const dlx = defineExchange('orders-dlx',
|
|
1857
|
+
const dlx = defineExchange('orders-dlx', { type: 'direct' });
|
|
1826
1858
|
const orderQueue = defineQueue('order-processing', {
|
|
1827
1859
|
deadLetter: { exchange: dlx },
|
|
1828
1860
|
retry: { mode: 'ttl-backoff', maxRetries: 5 },
|
|
@@ -1833,12 +1865,10 @@ const orderQueue = defineQueue('order-processing', {
|
|
|
1833
1865
|
#### Call Signature
|
|
1834
1866
|
|
|
1835
1867
|
```ts
|
|
1836
|
-
function defineQueue<TName>(name, options?):
|
|
1837
|
-
| QueueDefinition<TName>
|
|
1838
|
-
| QueueWithTtlBackoffInfrastructure<TName>;
|
|
1868
|
+
function defineQueue<TName>(name, options?): QueueEntry<TName>;
|
|
1839
1869
|
```
|
|
1840
1870
|
|
|
1841
|
-
Defined in: [builder/queue.ts:
|
|
1871
|
+
Defined in: [builder/queue.ts:118](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/queue.ts#L118)
|
|
1842
1872
|
|
|
1843
1873
|
Define an AMQP queue.
|
|
1844
1874
|
|
|
@@ -1864,8 +1894,7 @@ or priority queues.
|
|
|
1864
1894
|
|
|
1865
1895
|
##### Returns
|
|
1866
1896
|
|
|
1867
|
-
|
|
1868
|
-
\| [`QueueWithTtlBackoffInfrastructure`](#queuewithttlbackoffinfrastructure)<`TName`>
|
|
1897
|
+
[`QueueEntry`](#queueentry)<`TName`>
|
|
1869
1898
|
|
|
1870
1899
|
A queue definition
|
|
1871
1900
|
|
|
@@ -1876,7 +1905,7 @@ A queue definition
|
|
|
1876
1905
|
const orderQueue = defineQueue('order-processing');
|
|
1877
1906
|
|
|
1878
1907
|
// Explicit quorum queue with dead letter exchange
|
|
1879
|
-
const dlx = defineExchange('orders-dlx'
|
|
1908
|
+
const dlx = defineExchange('orders-dlx');
|
|
1880
1909
|
const orderQueueWithDLX = defineQueue('order-processing', {
|
|
1881
1910
|
type: 'quorum',
|
|
1882
1911
|
deadLetter: {
|
|
@@ -1898,12 +1927,11 @@ const tempQueue = defineQueue('temp-queue', {
|
|
|
1898
1927
|
// Priority queue (requires classic type)
|
|
1899
1928
|
const taskQueue = defineQueue('urgent-tasks', {
|
|
1900
1929
|
type: 'classic',
|
|
1901
|
-
durable: true,
|
|
1902
1930
|
maxPriority: 10,
|
|
1903
1931
|
});
|
|
1904
1932
|
|
|
1905
1933
|
// Queue with TTL-backoff retry (returns infrastructure automatically)
|
|
1906
|
-
const dlx = defineExchange('orders-dlx',
|
|
1934
|
+
const dlx = defineExchange('orders-dlx', { type: 'direct' });
|
|
1907
1935
|
const orderQueue = defineQueue('order-processing', {
|
|
1908
1936
|
deadLetter: { exchange: dlx },
|
|
1909
1937
|
retry: { mode: 'ttl-backoff', maxRetries: 5 },
|
|
@@ -1913,204 +1941,64 @@ const orderQueue = defineQueue('order-processing', {
|
|
|
1913
1941
|
|
|
1914
1942
|
***
|
|
1915
1943
|
|
|
1916
|
-
###
|
|
1917
|
-
|
|
1918
|
-
```ts
|
|
1919
|
-
function defineQuorumQueue<TName>(name, options): QuorumQueueDefinition<TName>;
|
|
1920
|
-
```
|
|
1921
|
-
|
|
1922
|
-
Defined in: [builder/queue.ts:460](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/queue.ts#L460)
|
|
1923
|
-
|
|
1924
|
-
Create a quorum queue with quorum-native retry.
|
|
1925
|
-
|
|
1926
|
-
This is a simplified helper that enforces best practices:
|
|
1927
|
-
- Uses quorum queues (recommended for most use cases)
|
|
1928
|
-
- Requires dead letter exchange for failed message handling
|
|
1929
|
-
- Uses quorum-native retry mode (simpler than TTL-backoff)
|
|
1930
|
-
|
|
1931
|
-
**When to use:**
|
|
1932
|
-
- You want simple, immediate retries without exponential backoff
|
|
1933
|
-
- You don't need configurable delays between retries
|
|
1934
|
-
- You want the simplest retry configuration
|
|
1935
|
-
|
|
1936
|
-
#### Type Parameters
|
|
1937
|
-
|
|
1938
|
-
| Type Parameter |
|
|
1939
|
-
| ------ |
|
|
1940
|
-
| `TName` *extends* `string` |
|
|
1941
|
-
|
|
1942
|
-
#### Parameters
|
|
1943
|
-
|
|
1944
|
-
| Parameter | Type | Description |
|
|
1945
|
-
| ------ | ------ | ------ |
|
|
1946
|
-
| `name` | `TName` | The queue name |
|
|
1947
|
-
| `options` | [`DefineQuorumQueueOptions`](#definequorumqueueoptions) | Configuration options |
|
|
1948
|
-
|
|
1949
|
-
#### Returns
|
|
1950
|
-
|
|
1951
|
-
[`QuorumQueueDefinition`](#quorumqueuedefinition)<`TName`>
|
|
1952
|
-
|
|
1953
|
-
A quorum queue definition with quorum-native retry
|
|
1954
|
-
|
|
1955
|
-
#### Example
|
|
1956
|
-
|
|
1957
|
-
```typescript
|
|
1958
|
-
const dlx = defineExchange('orders-dlx', 'direct', { durable: true });
|
|
1959
|
-
|
|
1960
|
-
const orderQueue = defineQuorumQueue('order-processing', {
|
|
1961
|
-
deadLetter: { exchange: dlx },
|
|
1962
|
-
deliveryLimit: 3, // Retry up to 3 times
|
|
1963
|
-
});
|
|
1964
|
-
|
|
1965
|
-
// Use in a contract — exchanges, queues, and bindings are auto-extracted
|
|
1966
|
-
const contract = defineContract({
|
|
1967
|
-
publishers: { ... },
|
|
1968
|
-
consumers: { processOrder: defineEventConsumer(event, orderQueue) },
|
|
1969
|
-
});
|
|
1970
|
-
```
|
|
1971
|
-
|
|
1972
|
-
#### See
|
|
1973
|
-
|
|
1974
|
-
- defineQueue - For full queue configuration options
|
|
1975
|
-
- defineTtlBackoffQueue - For queues with exponential backoff retry
|
|
1976
|
-
|
|
1977
|
-
***
|
|
1978
|
-
|
|
1979
|
-
### defineTtlBackoffQueue()
|
|
1944
|
+
### defineRpc()
|
|
1980
1945
|
|
|
1981
1946
|
```ts
|
|
1982
|
-
function
|
|
1947
|
+
function defineRpc<TRequestMessage, TResponseMessage, TQueue>(queue, messages): RpcDefinition<TRequestMessage, TResponseMessage, TQueue>;
|
|
1983
1948
|
```
|
|
1984
1949
|
|
|
1985
|
-
Defined in: [builder/
|
|
1986
|
-
|
|
1987
|
-
Create a queue with TTL-backoff retry (exponential backoff).
|
|
1950
|
+
Defined in: [builder/rpc.ts:41](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/rpc.ts#L41)
|
|
1988
1951
|
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
- Requires dead letter exchange for retry routing
|
|
1992
|
-
- Uses TTL-backoff retry mode with configurable delays
|
|
1993
|
-
- Automatically generates wait queue and bindings
|
|
1952
|
+
Define an RPC operation: a request/response pair flowing over a request
|
|
1953
|
+
queue with replies routed back via RabbitMQ direct reply-to.
|
|
1994
1954
|
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1955
|
+
RPC is bidirectional on both ends — the worker handler consumes the request
|
|
1956
|
+
and produces the response; `client.call(name, request, options)` publishes
|
|
1957
|
+
the request and awaits the typed response. Both sides share the same
|
|
1958
|
+
definition, so request and response schemas cannot drift between them.
|
|
1999
1959
|
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
and it will be expanded automatically.
|
|
1960
|
+
Plug the result into `defineContract({ rpcs: { name: ... } })`. RPCs do not
|
|
1961
|
+
appear in `publishers` or `consumers`.
|
|
2003
1962
|
|
|
2004
1963
|
#### Type Parameters
|
|
2005
1964
|
|
|
2006
1965
|
| Type Parameter |
|
|
2007
1966
|
| ------ |
|
|
2008
|
-
| `
|
|
1967
|
+
| `TRequestMessage` *extends* [`MessageDefinition`](#messagedefinition) |
|
|
1968
|
+
| `TResponseMessage` *extends* [`MessageDefinition`](#messagedefinition) |
|
|
1969
|
+
| `TQueue` *extends* [`QueueEntry`](#queueentry) |
|
|
2009
1970
|
|
|
2010
1971
|
#### Parameters
|
|
2011
1972
|
|
|
2012
1973
|
| Parameter | Type | Description |
|
|
2013
1974
|
| ------ | ------ | ------ |
|
|
2014
|
-
| `
|
|
2015
|
-
| `
|
|
1975
|
+
| `queue` | `TQueue` | The queue that receives RPC requests. The queue name is used as the routing key on the AMQP default direct exchange. |
|
|
1976
|
+
| `messages` | \{ `request`: `TRequestMessage`; `response`: `TResponseMessage`; \} | - |
|
|
1977
|
+
| `messages.request` | `TRequestMessage` | Schema validated against incoming request payloads (server side) and outgoing requests (client side). |
|
|
1978
|
+
| `messages.response` | `TResponseMessage` | Schema validated against handler return values (server side) and incoming replies (client side). |
|
|
2016
1979
|
|
|
2017
1980
|
#### Returns
|
|
2018
1981
|
|
|
2019
|
-
[`
|
|
2020
|
-
|
|
2021
|
-
A queue with TTL-backoff infrastructure
|
|
1982
|
+
[`RpcDefinition`](#rpcdefinition)<`TRequestMessage`, `TResponseMessage`, `TQueue`>
|
|
2022
1983
|
|
|
2023
1984
|
#### Example
|
|
2024
1985
|
|
|
2025
1986
|
```typescript
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
const orderQueue = defineTtlBackoffQueue('order-processing', {
|
|
2029
|
-
deadLetter: { exchange: dlx },
|
|
2030
|
-
maxRetries: 5,
|
|
2031
|
-
initialDelayMs: 1000, // Start with 1s delay
|
|
2032
|
-
maxDelayMs: 30000, // Cap at 30s
|
|
2033
|
-
});
|
|
1987
|
+
import { defineQueue, defineMessage, defineRpc, defineContract } from '@amqp-contract/contract';
|
|
1988
|
+
import { z } from 'zod';
|
|
2034
1989
|
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
consumers: { processOrder: defineEventConsumer(event, extractQueue(orderQueue)) },
|
|
1990
|
+
const calculate = defineRpc(defineQueue('rpc.calculate'), {
|
|
1991
|
+
request: defineMessage(z.object({ a: z.number(), b: z.number() })),
|
|
1992
|
+
response: defineMessage(z.object({ sum: z.number() })),
|
|
2039
1993
|
});
|
|
2040
1994
|
|
|
2041
|
-
|
|
2042
|
-
import { extractQueue } from '@amqp-contract/contract';
|
|
2043
|
-
const queueName = extractQueue(orderQueue).name;
|
|
2044
|
-
```
|
|
1995
|
+
const contract = defineContract({ rpcs: { calculate } });
|
|
2045
1996
|
|
|
2046
|
-
|
|
1997
|
+
// Server (worker): handler returns the typed response
|
|
1998
|
+
// handlers: { calculate: ({ payload }) => Future.value(Result.Ok({ sum: payload.a + payload.b })) }
|
|
2047
1999
|
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
- extractQueue - To access the underlying queue definition
|
|
2051
|
-
|
|
2052
|
-
***
|
|
2053
|
-
|
|
2054
|
-
### defineTtlBackoffRetryInfrastructure()
|
|
2055
|
-
|
|
2056
|
-
```ts
|
|
2057
|
-
function defineTtlBackoffRetryInfrastructure(queueEntry, options?): TtlBackoffRetryInfrastructure;
|
|
2058
|
-
```
|
|
2059
|
-
|
|
2060
|
-
Defined in: [builder/ttl-backoff.ts:67](https://github.com/btravers/amqp-contract/blob/04791f62e768b84b07aa5288adb8ab72296d6663/packages/contract/src/builder/ttl-backoff.ts#L67)
|
|
2061
|
-
|
|
2062
|
-
Create TTL-backoff retry infrastructure for a queue.
|
|
2063
|
-
|
|
2064
|
-
This builder helper generates the wait queue and bindings needed for TTL-backoff retry.
|
|
2065
|
-
The generated infrastructure can be spread into a contract definition.
|
|
2066
|
-
|
|
2067
|
-
TTL-backoff retry works by:
|
|
2068
|
-
1. Failed messages are sent to the DLX with routing key `{queueName}-wait`
|
|
2069
|
-
2. The wait queue receives these messages and holds them for a TTL period
|
|
2070
|
-
3. After TTL expires, messages are dead-lettered back to the DLX with routing key `{queueName}`
|
|
2071
|
-
4. The main queue receives the retried message via its binding to the DLX
|
|
2072
|
-
|
|
2073
|
-
#### Parameters
|
|
2074
|
-
|
|
2075
|
-
| Parameter | Type | Description |
|
|
2076
|
-
| ------ | ------ | ------ |
|
|
2077
|
-
| `queueEntry` | [`QueueEntry`](#queueentry) | - |
|
|
2078
|
-
| `options?` | \{ `waitQueueDurable?`: `boolean`; \} | Optional configuration for the wait queue |
|
|
2079
|
-
| `options.waitQueueDurable?` | `boolean` | Whether the wait queue should be durable (default: same as main queue) |
|
|
2080
|
-
|
|
2081
|
-
#### Returns
|
|
2082
|
-
|
|
2083
|
-
[`TtlBackoffRetryInfrastructure`](#ttlbackoffretryinfrastructure)
|
|
2084
|
-
|
|
2085
|
-
TTL-backoff retry infrastructure containing wait queue and bindings
|
|
2086
|
-
|
|
2087
|
-
#### Throws
|
|
2088
|
-
|
|
2089
|
-
If the queue does not have a dead letter exchange configured
|
|
2090
|
-
|
|
2091
|
-
#### Example
|
|
2092
|
-
|
|
2093
|
-
```typescript
|
|
2094
|
-
const dlx = defineExchange('orders-dlx', 'direct', { durable: true });
|
|
2095
|
-
const orderQueue = defineQueue('order-processing', {
|
|
2096
|
-
type: 'quorum',
|
|
2097
|
-
deadLetter: { exchange: dlx },
|
|
2098
|
-
retry: {
|
|
2099
|
-
mode: 'ttl-backoff',
|
|
2100
|
-
maxRetries: 5,
|
|
2101
|
-
initialDelayMs: 1000,
|
|
2102
|
-
},
|
|
2103
|
-
});
|
|
2104
|
-
|
|
2105
|
-
// Infrastructure is auto-extracted when using defineContract:
|
|
2106
|
-
const contract = defineContract({
|
|
2107
|
-
publishers: { ... },
|
|
2108
|
-
consumers: { processOrder: defineEventConsumer(event, extractQueue(orderQueue)) },
|
|
2109
|
-
});
|
|
2110
|
-
// contract.queues includes the wait queue, contract.bindings includes retry bindings
|
|
2111
|
-
|
|
2112
|
-
// Or generate manually for advanced use cases:
|
|
2113
|
-
const retryInfra = defineTtlBackoffRetryInfrastructure(orderQueue);
|
|
2000
|
+
// Client: typed call with required timeout
|
|
2001
|
+
// const result = await client.call('calculate', { a: 1, b: 2 }, { timeoutMs: 5_000 }).toPromise();
|
|
2114
2002
|
```
|
|
2115
2003
|
|
|
2116
2004
|
***
|
|
@@ -2121,7 +2009,7 @@ const retryInfra = defineTtlBackoffRetryInfrastructure(orderQueue);
|
|
|
2121
2009
|
function extractConsumer(entry): ConsumerDefinition;
|
|
2122
2010
|
```
|
|
2123
2011
|
|
|
2124
|
-
Defined in: [builder/consumer.ts:
|
|
2012
|
+
Defined in: [builder/consumer.ts:54](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/consumer.ts#L54)
|
|
2125
2013
|
|
|
2126
2014
|
Extract the ConsumerDefinition from any ConsumerEntry type.
|
|
2127
2015
|
|
|
@@ -2170,18 +2058,18 @@ extractConsumer(consumer3).queue.name; // "my-queue"
|
|
|
2170
2058
|
function extractQueue<T>(entry): ExtractQueueFromEntry<T>;
|
|
2171
2059
|
```
|
|
2172
2060
|
|
|
2173
|
-
Defined in: [builder/queue.ts:
|
|
2061
|
+
Defined in: [builder/queue-utils.ts:60](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/queue-utils.ts#L60)
|
|
2174
2062
|
|
|
2175
2063
|
Extract the plain QueueDefinition from a QueueEntry.
|
|
2176
2064
|
|
|
2177
2065
|
**Why this function exists:**
|
|
2178
|
-
When you configure a queue with TTL-backoff retry
|
|
2179
|
-
`defineQueue`
|
|
2180
|
-
the main queue, wait queue, and bindings. This function extracts the underlying
|
|
2066
|
+
When you configure a queue with TTL-backoff retry,
|
|
2067
|
+
`defineQueue` returns a wrapper object that includes
|
|
2068
|
+
the main queue, wait queue, headers exchanges, and bindings. This function extracts the underlying
|
|
2181
2069
|
queue definition so you can access properties like `name`, `type`, etc.
|
|
2182
2070
|
|
|
2183
2071
|
**When to use:**
|
|
2184
|
-
- When you need to access queue properties (name, type,
|
|
2072
|
+
- When you need to access queue properties (name, type, etc.)
|
|
2185
2073
|
- When passing a queue to functions that expect a plain QueueDefinition
|
|
2186
2074
|
- Works safely on both plain queues and infrastructure wrappers
|
|
2187
2075
|
|
|
@@ -2210,32 +2098,29 @@ The plain QueueDefinition
|
|
|
2210
2098
|
#### Example
|
|
2211
2099
|
|
|
2212
2100
|
```typescript
|
|
2213
|
-
import { defineQueue,
|
|
2101
|
+
import { defineQueue, extractQueue } from '@amqp-contract/contract';
|
|
2214
2102
|
|
|
2215
2103
|
// TTL-backoff queue returns a wrapper
|
|
2216
|
-
const orderQueue =
|
|
2217
|
-
|
|
2218
|
-
maxRetries: 3,
|
|
2104
|
+
const orderQueue = defineQueue('orders', {
|
|
2105
|
+
retry: { mode: 'ttl-backoff', maxRetries: 3 },
|
|
2219
2106
|
});
|
|
2220
2107
|
|
|
2221
2108
|
// Use extractQueue to access the queue name
|
|
2222
2109
|
const queueName = extractQueue(orderQueue).name; // 'orders'
|
|
2223
2110
|
|
|
2224
2111
|
// Also works safely on plain queues
|
|
2225
|
-
const plainQueue = defineQueue('simple', { type: 'quorum', retry: { mode: '
|
|
2112
|
+
const plainQueue = defineQueue('simple', { type: 'quorum', retry: { mode: 'immediate-requeue' } });
|
|
2226
2113
|
const plainName = extractQueue(plainQueue).name; // 'simple'
|
|
2227
2114
|
|
|
2228
2115
|
// Access other properties
|
|
2229
2116
|
const queueDef = extractQueue(orderQueue);
|
|
2230
2117
|
console.log(queueDef.name); // 'orders'
|
|
2231
2118
|
console.log(queueDef.type); // 'quorum'
|
|
2232
|
-
console.log(queueDef.deadLetter); // { exchange: dlx, ... }
|
|
2233
2119
|
```
|
|
2234
2120
|
|
|
2235
2121
|
#### See
|
|
2236
2122
|
|
|
2237
|
-
|
|
2238
|
-
- defineTtlBackoffQueue - Creates queues with TTL-backoff infrastructure
|
|
2123
|
+
isQueueWithTtlBackoffInfrastructure - Type guard to check if extraction is needed
|
|
2239
2124
|
|
|
2240
2125
|
***
|
|
2241
2126
|
|
|
@@ -2245,7 +2130,7 @@ console.log(queueDef.deadLetter); // { exchange: dlx, ... }
|
|
|
2245
2130
|
function isBridgedPublisherConfig(value): value is BridgedPublisherConfig<MessageDefinition, ExchangeDefinition, ExchangeDefinition>;
|
|
2246
2131
|
```
|
|
2247
2132
|
|
|
2248
|
-
Defined in: [builder/command.ts:
|
|
2133
|
+
Defined in: [builder/command.ts:514](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L514)
|
|
2249
2134
|
|
|
2250
2135
|
Type guard to check if a value is a BridgedPublisherConfig.
|
|
2251
2136
|
|
|
@@ -2266,10 +2151,10 @@ True if the value is a BridgedPublisherConfig
|
|
|
2266
2151
|
### isCommandConsumerConfig()
|
|
2267
2152
|
|
|
2268
2153
|
```ts
|
|
2269
|
-
function isCommandConsumerConfig(value): value is CommandConsumerConfig<MessageDefinition, ExchangeDefinition, string | undefined,
|
|
2154
|
+
function isCommandConsumerConfig(value): value is CommandConsumerConfig<MessageDefinition, ExchangeDefinition, string | undefined, QueueEntry>;
|
|
2270
2155
|
```
|
|
2271
2156
|
|
|
2272
|
-
Defined in: [builder/command.ts:
|
|
2157
|
+
Defined in: [builder/command.ts:497](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/command.ts#L497)
|
|
2273
2158
|
|
|
2274
2159
|
Type guard to check if a value is a CommandConsumerConfig.
|
|
2275
2160
|
|
|
@@ -2281,7 +2166,7 @@ Type guard to check if a value is a CommandConsumerConfig.
|
|
|
2281
2166
|
|
|
2282
2167
|
#### Returns
|
|
2283
2168
|
|
|
2284
|
-
value is CommandConsumerConfig\<MessageDefinition, ExchangeDefinition, string \| undefined,
|
|
2169
|
+
value is CommandConsumerConfig\<MessageDefinition, ExchangeDefinition, string \| undefined, QueueEntry\>
|
|
2285
2170
|
|
|
2286
2171
|
True if the value is a CommandConsumerConfig
|
|
2287
2172
|
|
|
@@ -2290,10 +2175,10 @@ True if the value is a CommandConsumerConfig
|
|
|
2290
2175
|
### isEventConsumerResult()
|
|
2291
2176
|
|
|
2292
2177
|
```ts
|
|
2293
|
-
function isEventConsumerResult(value): value is EventConsumerResult<MessageDefinition, ExchangeDefinition,
|
|
2178
|
+
function isEventConsumerResult(value): value is EventConsumerResult<MessageDefinition, ExchangeDefinition, QueueEntry, ExchangeBindingDefinition | undefined, ExchangeDefinition | undefined>;
|
|
2294
2179
|
```
|
|
2295
2180
|
|
|
2296
|
-
Defined in: [builder/event.ts:
|
|
2181
|
+
Defined in: [builder/event.ts:616](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L616)
|
|
2297
2182
|
|
|
2298
2183
|
Type guard to check if a value is an EventConsumerResult.
|
|
2299
2184
|
|
|
@@ -2305,7 +2190,7 @@ Type guard to check if a value is an EventConsumerResult.
|
|
|
2305
2190
|
|
|
2306
2191
|
#### Returns
|
|
2307
2192
|
|
|
2308
|
-
value is EventConsumerResult\<MessageDefinition, ExchangeDefinition,
|
|
2193
|
+
value is EventConsumerResult\<MessageDefinition, ExchangeDefinition, QueueEntry, ExchangeBindingDefinition \| undefined, ExchangeDefinition \| undefined\>
|
|
2309
2194
|
|
|
2310
2195
|
True if the value is an EventConsumerResult
|
|
2311
2196
|
|
|
@@ -2317,7 +2202,7 @@ True if the value is an EventConsumerResult
|
|
|
2317
2202
|
function isEventPublisherConfig(value): value is EventPublisherConfig<MessageDefinition, ExchangeDefinition, string | undefined>;
|
|
2318
2203
|
```
|
|
2319
2204
|
|
|
2320
|
-
Defined in: [builder/event.ts:
|
|
2205
|
+
Defined in: [builder/event.ts:599](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/event.ts#L599)
|
|
2321
2206
|
|
|
2322
2207
|
Type guard to check if a value is an EventPublisherConfig.
|
|
2323
2208
|
|
|
@@ -2341,11 +2226,11 @@ True if the value is an EventPublisherConfig
|
|
|
2341
2226
|
function isQueueWithTtlBackoffInfrastructure(entry): entry is QueueWithTtlBackoffInfrastructure;
|
|
2342
2227
|
```
|
|
2343
2228
|
|
|
2344
|
-
Defined in: [builder/
|
|
2229
|
+
Defined in: [builder/ttl-backoff.ts:43](https://github.com/btravers/amqp-contract/blob/da9b95c747db8d5af9183ca6fe2a6e0af558d1fa/packages/contract/src/builder/ttl-backoff.ts#L43)
|
|
2345
2230
|
|
|
2346
2231
|
Type guard to check if a queue entry is a QueueWithTtlBackoffInfrastructure.
|
|
2347
2232
|
|
|
2348
|
-
When you configure a queue with TTL-backoff retry
|
|
2233
|
+
When you configure a queue with TTL-backoff retry,
|
|
2349
2234
|
`defineQueue` returns a `QueueWithTtlBackoffInfrastructure` instead of a plain
|
|
2350
2235
|
`QueueDefinition`. This type guard helps you distinguish between the two.
|
|
2351
2236
|
|
|
@@ -2372,12 +2257,11 @@ True if the entry is a QueueWithTtlBackoffInfrastructure, false otherwise
|
|
|
2372
2257
|
|
|
2373
2258
|
```typescript
|
|
2374
2259
|
const queue = defineQueue('orders', {
|
|
2375
|
-
deadLetter: { exchange: dlx },
|
|
2376
2260
|
retry: { mode: 'ttl-backoff' },
|
|
2377
2261
|
});
|
|
2378
2262
|
|
|
2379
2263
|
if (isQueueWithTtlBackoffInfrastructure(queue)) {
|
|
2380
|
-
// queue has .queue, .waitQueue, .waitQueueBinding, .
|
|
2264
|
+
// queue has .queue, .waitQueue, .waitQueueBinding, .retryQueueBinding, .waitExchange, .retryExchange
|
|
2381
2265
|
console.log('Wait queue:', queue.waitQueue.name);
|
|
2382
2266
|
} else {
|
|
2383
2267
|
// queue is a plain QueueDefinition
|