@amqp-contract/contract 0.9.0 → 0.11.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/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/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L12)
15
+ Defined in: [types.ts:12](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/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 = object;
33
33
  ```
34
34
 
35
- Defined in: [types.ts:50](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L50)
35
+ Defined in: [types.ts:350](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L350)
36
36
 
37
37
  Base definition of an AMQP exchange.
38
38
 
@@ -43,11 +43,11 @@ type and routing rules. This type contains properties common to all exchange typ
43
43
 
44
44
  | Property | Type | Description | Defined in |
45
45
  | ------ | ------ | ------ | ------ |
46
- | <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:79](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L79) |
47
- | <a id="autodelete"></a> `autoDelete?` | `boolean` | If true, the exchange is deleted when all queues have finished using it. **Default** `false` | [types.ts:66](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L66) |
48
- | <a id="durable"></a> `durable?` | `boolean` | If true, the exchange survives broker restarts. Durable exchanges are persisted to disk. **Default** `false` | [types.ts:60](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L60) |
49
- | <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. **Default** `false` | [types.ts:73](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L73) |
50
- | <a id="name"></a> `name` | `string` | The name of the exchange. Must be unique within the RabbitMQ virtual host. | [types.ts:54](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L54) |
46
+ | <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:379](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L379) |
47
+ | <a id="autodelete"></a> `autoDelete?` | `boolean` | If true, the exchange is deleted when all queues have finished using it. **Default** `false` | [types.ts:366](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L366) |
48
+ | <a id="durable"></a> `durable?` | `boolean` | If true, the exchange survives broker restarts. Durable exchanges are persisted to disk. **Default** `false` | [types.ts:360](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L360) |
49
+ | <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. **Default** `false` | [types.ts:373](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L373) |
50
+ | <a id="name"></a> `name` | `string` | The name of the exchange. Must be unique within the RabbitMQ virtual host. | [types.ts:354](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L354) |
51
51
 
52
52
  ***
53
53
 
@@ -59,7 +59,7 @@ type BindingDefinition =
59
59
  | ExchangeBindingDefinition;
60
60
  ```
61
61
 
62
- Defined in: [types.ts:370](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L370)
62
+ Defined in: [types.ts:786](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L786)
63
63
 
64
64
  Union type of all binding definitions.
65
65
 
@@ -75,7 +75,7 @@ A binding can be either:
75
75
  type BindingPattern<S> = S extends "" ? never : S;
76
76
  ```
77
77
 
78
- Defined in: [builder.ts:844](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L844)
78
+ Defined in: [builder.ts:1069](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1069)
79
79
 
80
80
  Type-safe binding pattern that validates basic format and wildcards.
81
81
 
@@ -104,13 +104,73 @@ type Invalid = BindingPattern<"">; // never (empty string)
104
104
 
105
105
  ***
106
106
 
107
+ ### ClassicQueueDefinition
108
+
109
+ ```ts
110
+ type ClassicQueueDefinition = BaseQueueDefinition & object;
111
+ ```
112
+
113
+ Defined in: [types.ts:564](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L564)
114
+
115
+ Definition of a classic queue.
116
+
117
+ Classic queues are the traditional RabbitMQ queue type. Use them when you need
118
+ specific features not supported by quorum queues (e.g., exclusive queues, priority queues).
119
+
120
+ #### Type Declaration
121
+
122
+ | Name | Type | Description | Defined in |
123
+ | ------ | ------ | ------ | ------ |
124
+ | `deliveryLimit?` | `never` | Classic queues do not support delivery limits. Use type: 'quorum' if you need native retry with delivery limits. | [types.ts:574](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L574) |
125
+ | `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. **Default** `false` | [types.ts:581](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L581) |
126
+ | `retry?` | [`TtlBackoffRetryOptions`](#ttlbackoffretryoptions) | Retry configuration for handling failed message processing. Classic queues only support TTL-backoff retry mode. | [types.ts:588](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L588) |
127
+ | `type` | `"classic"` | Queue type discriminator: classic queue. | [types.ts:568](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L568) |
128
+
129
+ ***
130
+
131
+ ### ClassicQueueOptions
132
+
133
+ ```ts
134
+ type ClassicQueueOptions = BaseQueueOptions & object;
135
+ ```
136
+
137
+ Defined in: [types.ts:292](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L292)
138
+
139
+ Options for creating a classic queue.
140
+
141
+ Classic queues support all traditional RabbitMQ features including:
142
+ - `exclusive: true` - For connection-scoped queues
143
+ - `maxPriority` - For priority queues
144
+ - `durable: false` - For non-durable queues
145
+
146
+ #### Type Declaration
147
+
148
+ | Name | Type | Description | Defined in |
149
+ | ------ | ------ | ------ | ------ |
150
+ | `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. **Default** `false` | [types.ts:303](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L303) |
151
+ | `maxPriority?` | `number` | Maximum priority level for priority queue (1-255, recommended: 1-10). Sets x-max-priority argument. Only supported with classic queues. | [types.ts:310](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L310) |
152
+ | `retry?` | [`TtlBackoffRetryOptions`](#ttlbackoffretryoptions) | Retry configuration for handling failed message processing. Classic queues only support TTL-backoff retry mode, which uses wait queues with exponential backoff. For quorum-native retry, use quorum queues instead. **Example** `const orderQueue = defineQueue('order-processing', { type: 'classic', durable: true, deadLetter: { exchange: dlx }, retry: { maxRetries: 5, initialDelayMs: 1000, maxDelayMs: 30000, }, });` | [types.ts:332](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L332) |
153
+ | `type` | `"classic"` | Queue type: classic (for special cases) | [types.ts:296](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L296) |
154
+
155
+ #### Example
156
+
157
+ ```typescript
158
+ const priorityQueue = defineQueue('tasks', {
159
+ type: 'classic',
160
+ durable: true,
161
+ maxPriority: 10,
162
+ });
163
+ ```
164
+
165
+ ***
166
+
107
167
  ### CompressionAlgorithm
108
168
 
109
169
  ```ts
110
170
  type CompressionAlgorithm = "gzip" | "deflate";
111
171
  ```
112
172
 
113
- Defined in: [types.ts:42](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L42)
173
+ Defined in: [types.ts:108](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L108)
114
174
 
115
175
  Supported compression algorithms for message payloads.
116
176
 
@@ -148,7 +208,7 @@ await client.publish("orderCreated", payload, {
148
208
  type ConsumerDefinition<TMessage> = object;
149
209
  ```
150
210
 
151
- Defined in: [types.ts:431](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L431)
211
+ Defined in: [types.ts:847](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L847)
152
212
 
153
213
  Definition of a message consumer.
154
214
 
@@ -176,8 +236,8 @@ const consumer: ConsumerDefinition = {
176
236
 
177
237
  | Property | Type | Description | Defined in |
178
238
  | ------ | ------ | ------ | ------ |
179
- | <a id="message"></a> `message` | `TMessage` | The message definition including the payload schema | [types.ts:436](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L436) |
180
- | <a id="queue"></a> `queue` | [`QueueDefinition`](#queuedefinition) | The queue to consume messages from | [types.ts:433](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L433) |
239
+ | <a id="message"></a> `message` | `TMessage` | The message definition including the payload schema | [types.ts:852](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L852) |
240
+ | <a id="queue"></a> `queue` | [`QueueDefinition`](#queuedefinition) | The queue to consume messages from | [types.ts:849](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L849) |
181
241
 
182
242
  ***
183
243
 
@@ -187,7 +247,7 @@ const consumer: ConsumerDefinition = {
187
247
  type ConsumerFirstResult<TMessage, TConsumer, TBinding> = object;
188
248
  ```
189
249
 
190
- Defined in: [builder.ts:1221](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L1221)
250
+ Defined in: [builder.ts:1446](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1446)
191
251
 
192
252
  Consumer-first builder result for fanout and direct exchanges.
193
253
 
@@ -206,9 +266,9 @@ a publisher that uses the same message schema and routing key.
206
266
 
207
267
  | Property | Type | Description | Defined in |
208
268
  | ------ | ------ | ------ | ------ |
209
- | <a id="binding"></a> `binding` | `TBinding` | The binding definition connecting the exchange to the queue | [builder.ts:1229](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L1229) |
210
- | <a id="consumer"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:1227](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L1227) |
211
- | <a id="createpublisher"></a> `createPublisher` | () => `TBinding`\[`"exchange"`\] *extends* [`FanoutExchangeDefinition`](#fanoutexchangedefinition) ? `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: [`FanoutExchangeDefinition`](#fanoutexchangedefinition); \}\> : `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: \| [`DirectExchangeDefinition`](#directexchangedefinition) \| [`TopicExchangeDefinition`](#topicexchangedefinition); \}\> | Create a publisher that sends messages to this consumer. The publisher will automatically use the same message schema and routing key. | [builder.ts:1236](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L1236) |
269
+ | <a id="binding"></a> `binding` | `TBinding` | The binding definition connecting the exchange to the queue | [builder.ts:1454](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1454) |
270
+ | <a id="consumer"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:1452](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1452) |
271
+ | <a id="createpublisher"></a> `createPublisher` | () => `TBinding`\[`"exchange"`\] *extends* [`FanoutExchangeDefinition`](#fanoutexchangedefinition) ? `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: [`FanoutExchangeDefinition`](#fanoutexchangedefinition); \}\> : `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: \| [`DirectExchangeDefinition`](#directexchangedefinition) \| [`TopicExchangeDefinition`](#topicexchangedefinition); \}\> | Create a publisher that sends messages to this consumer. The publisher will automatically use the same message schema and routing key. | [builder.ts:1461](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1461) |
212
272
 
213
273
  ***
214
274
 
@@ -218,7 +278,7 @@ a publisher that uses the same message schema and routing key.
218
278
  type ConsumerFirstResultWithRoutingKey<TMessage, TConsumer, TBinding> = object;
219
279
  ```
220
280
 
221
- Defined in: [builder.ts:1254](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L1254)
281
+ Defined in: [builder.ts:1479](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1479)
222
282
 
223
283
  Consumer-first builder result for topic exchanges.
224
284
 
@@ -237,9 +297,9 @@ a method to create a publisher with a concrete routing key that matches the patt
237
297
 
238
298
  | Property | Type | Description | Defined in |
239
299
  | ------ | ------ | ------ | ------ |
240
- | <a id="binding-1"></a> `binding` | `TBinding` | The binding definition connecting the exchange to the queue | [builder.ts:1262](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L1262) |
241
- | <a id="consumer-1"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:1260](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L1260) |
242
- | <a id="createpublisher-1"></a> `createPublisher` | \<`TPublisherRoutingKey`\>(`routingKey`) => `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: \| [`DirectExchangeDefinition`](#directexchangedefinition) \| [`TopicExchangeDefinition`](#topicexchangedefinition); \}\> | Create a publisher that sends messages to this consumer. For topic exchanges, the routing key can be specified to match the binding pattern. | [builder.ts:1270](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L1270) |
300
+ | <a id="binding-1"></a> `binding` | `TBinding` | The binding definition connecting the exchange to the queue | [builder.ts:1487](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1487) |
301
+ | <a id="consumer-1"></a> `consumer` | `TConsumer` | The consumer definition | [builder.ts:1485](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1485) |
302
+ | <a id="createpublisher-1"></a> `createPublisher` | \<`TPublisherRoutingKey`\>(`routingKey`) => `Extract`\<[`PublisherDefinition`](#publisherdefinition)\<`TMessage`\>, \{ `exchange`: \| [`DirectExchangeDefinition`](#directexchangedefinition) \| [`TopicExchangeDefinition`](#topicexchangedefinition); \}\> | Create a publisher that sends messages to this consumer. For topic exchanges, the routing key can be specified to match the binding pattern. | [builder.ts:1495](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1495) |
243
303
 
244
304
  ***
245
305
 
@@ -249,7 +309,7 @@ a method to create a publisher with a concrete routing key that matches the patt
249
309
  type ContractDefinition = object;
250
310
  ```
251
311
 
252
- Defined in: [types.ts:472](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L472)
312
+ Defined in: [types.ts:888](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L888)
253
313
 
254
314
  Complete AMQP contract definition.
255
315
 
@@ -288,11 +348,11 @@ const contract: ContractDefinition = {
288
348
 
289
349
  | Property | Type | Description | Defined in |
290
350
  | ------ | ------ | ------ | ------ |
291
- | <a id="bindings"></a> `bindings?` | `Record`\<`string`, [`BindingDefinition`](#bindingdefinition)\> | Named binding definitions. Bindings can be queue-to-exchange or exchange-to-exchange. | [types.ts:489](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L489) |
292
- | <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:503](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L503) |
293
- | <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:477](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L477) |
294
- | <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:496](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L496) |
295
- | <a id="queues"></a> `queues?` | `Record`\<`string`, [`QueueDefinition`](#queuedefinition)\> | Named queue definitions. Each key becomes available as a named resource in the contract. | [types.ts:483](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L483) |
351
+ | <a id="bindings"></a> `bindings?` | `Record`\<`string`, [`BindingDefinition`](#bindingdefinition)\> | Named binding definitions. Bindings can be queue-to-exchange or exchange-to-exchange. | [types.ts:908](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L908) |
352
+ | <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:922](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L922) |
353
+ | <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:893](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L893) |
354
+ | <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:915](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L915) |
355
+ | <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:902](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L902) |
296
356
 
297
357
  ***
298
358
 
@@ -302,7 +362,7 @@ const contract: ContractDefinition = {
302
362
  type DeadLetterConfig = object;
303
363
  ```
304
364
 
305
- Defined in: [types.ts:154](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L154)
365
+ Defined in: [types.ts:454](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L454)
306
366
 
307
367
  Configuration for dead letter exchange (DLX) on a queue.
308
368
 
@@ -314,8 +374,26 @@ or storage.
314
374
 
315
375
  | Property | Type | Description | Defined in |
316
376
  | ------ | ------ | ------ | ------ |
317
- | <a id="exchange"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | The exchange to send dead-lettered messages to. This exchange must be declared in the contract. | [types.ts:159](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L159) |
318
- | <a id="routingkey"></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:165](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L165) |
377
+ | <a id="exchange"></a> `exchange` | [`ExchangeDefinition`](#exchangedefinition) | The exchange to send dead-lettered messages to. This exchange must be declared in the contract. | [types.ts:459](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L459) |
378
+ | <a id="routingkey"></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:465](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L465) |
379
+
380
+ ***
381
+
382
+ ### DefineQueueOptions
383
+
384
+ ```ts
385
+ type DefineQueueOptions =
386
+ | QuorumQueueOptions
387
+ | ClassicQueueOptions;
388
+ ```
389
+
390
+ Defined in: [types.ts:342](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L342)
391
+
392
+ Options for defining a queue. Uses a discriminated union based on the `type` property
393
+ to enforce quorum queue constraints at compile time.
394
+
395
+ - Quorum queues (default): Do not support `exclusive` or `maxPriority`
396
+ - Classic queues: Support all options including `exclusive` and `maxPriority`
319
397
 
320
398
  ***
321
399
 
@@ -325,7 +403,7 @@ or storage.
325
403
  type DirectExchangeDefinition = BaseExchangeDefinition & object;
326
404
  ```
327
405
 
328
- Defined in: [types.ts:112](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L112)
406
+ Defined in: [types.ts:412](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L412)
329
407
 
330
408
  A direct exchange definition.
331
409
 
@@ -336,7 +414,7 @@ This is ideal for point-to-point messaging where each message should go to speci
336
414
 
337
415
  | Name | Type | Defined in |
338
416
  | ------ | ------ | ------ |
339
- | `type` | `"direct"` | [types.ts:113](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L113) |
417
+ | `type` | `"direct"` | [types.ts:413](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L413) |
340
418
 
341
419
  #### Example
342
420
 
@@ -363,7 +441,7 @@ type ExchangeBindingDefinition = object &
363
441
  };
364
442
  ```
365
443
 
366
- Defined in: [types.ts:334](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L334)
444
+ Defined in: [types.ts:750](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L750)
367
445
 
368
446
  Binding between two exchanges (exchange-to-exchange routing).
369
447
 
@@ -374,9 +452,9 @@ This allows for more complex routing topologies.
374
452
 
375
453
  | Name | Type | Description | Defined in |
376
454
  | ------ | ------ | ------ | ------ |
377
- | `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. | [types.ts:344](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L344) |
378
- | `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:339](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L339) |
379
- | `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:336](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L336) |
455
+ | `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. | [types.ts:760](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L760) |
456
+ | `destination` | [`ExchangeDefinition`](#exchangedefinition) | The destination exchange that will receive forwarded messages | [types.ts:755](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L755) |
457
+ | `type` | `"exchange"` | Discriminator indicating this is an exchange-to-exchange binding | [types.ts:752](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L752) |
380
458
 
381
459
  #### Example
382
460
 
@@ -401,7 +479,7 @@ type ExchangeDefinition =
401
479
  | TopicExchangeDefinition;
402
480
  ```
403
481
 
404
- Defined in: [types.ts:142](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L142)
482
+ Defined in: [types.ts:442](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L442)
405
483
 
406
484
  Union type of all exchange definitions.
407
485
 
@@ -415,7 +493,7 @@ Represents any type of AMQP exchange: fanout, direct, or topic.
415
493
  type FanoutExchangeDefinition = BaseExchangeDefinition & object;
416
494
  ```
417
495
 
418
- Defined in: [types.ts:95](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L95)
496
+ Defined in: [types.ts:395](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L395)
419
497
 
420
498
  A fanout exchange definition.
421
499
 
@@ -426,7 +504,7 @@ This is the simplest exchange type for pub/sub messaging patterns.
426
504
 
427
505
  | Name | Type | Defined in |
428
506
  | ------ | ------ | ------ |
429
- | `type` | `"fanout"` | [types.ts:96](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L96) |
507
+ | `type` | `"fanout"` | [types.ts:396](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L396) |
430
508
 
431
509
  #### Example
432
510
 
@@ -444,7 +522,7 @@ const logsExchange: FanoutExchangeDefinition = defineExchange('logs', 'fanout',
444
522
  type InferConsumerNames<TContract> = TContract["consumers"] extends Record<string, unknown> ? keyof TContract["consumers"] : never;
445
523
  ```
446
524
 
447
- Defined in: [types.ts:539](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L539)
525
+ Defined in: [types.ts:958](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L958)
448
526
 
449
527
  Extract consumer names from a contract.
450
528
 
@@ -476,7 +554,7 @@ type ConsumerNames = InferConsumerNames<typeof myContract>;
476
554
  type InferPublisherNames<TContract> = TContract["publishers"] extends Record<string, unknown> ? keyof TContract["publishers"] : never;
477
555
  ```
478
556
 
479
- Defined in: [types.ts:521](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L521)
557
+ Defined in: [types.ts:940](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L940)
480
558
 
481
559
  Extract publisher names from a contract.
482
560
 
@@ -508,7 +586,7 @@ type PublisherNames = InferPublisherNames<typeof myContract>;
508
586
  type MatchingRoutingKey<Pattern, Key> = RoutingKey<Key> extends never ? never : BindingPattern<Pattern> extends never ? never : MatchesPattern<Key, Pattern> extends true ? Key : never;
509
587
  ```
510
588
 
511
- Defined in: [builder.ts:906](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L906)
589
+ Defined in: [builder.ts:1131](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1131)
512
590
 
513
591
  Validate that a routing key matches a binding pattern.
514
592
 
@@ -540,7 +618,7 @@ type InvalidKey = MatchingRoutingKey<"order.*", "user.created">; // never
540
618
  type MessageDefinition<TPayload, THeaders> = object;
541
619
  ```
542
620
 
543
- Defined in: [types.ts:250](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L250)
621
+ Defined in: [types.ts:666](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L666)
544
622
 
545
623
  Definition of a message with typed payload and optional headers.
546
624
 
@@ -555,10 +633,10 @@ Definition of a message with typed payload and optional headers.
555
633
 
556
634
  | Property | Type | Description | Defined in |
557
635
  | ------ | ------ | ------ | ------ |
558
- | <a id="description"></a> `description?` | `string` | Detailed description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:276](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L276) |
559
- | <a id="headers"></a> `headers?` | `THeaders` | Optional headers schema for validating message metadata. Must be a Standard Schema v1 compatible schema. | [types.ts:264](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L264) |
560
- | <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:258](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L258) |
561
- | <a id="summary"></a> `summary?` | `string` | Brief description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:270](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L270) |
636
+ | <a id="description"></a> `description?` | `string` | Detailed description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:692](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L692) |
637
+ | <a id="headers"></a> `headers?` | `THeaders` | Optional headers schema for validating message metadata. Must be a Standard Schema v1 compatible schema. | [types.ts:680](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L680) |
638
+ | <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:674](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L674) |
639
+ | <a id="summary"></a> `summary?` | `string` | Brief description of the message for documentation purposes. Used in AsyncAPI specification generation. | [types.ts:686](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L686) |
562
640
 
563
641
  ***
564
642
 
@@ -577,7 +655,7 @@ type PublisherDefinition<TMessage> = object &
577
655
  };
578
656
  ```
579
657
 
580
- Defined in: [types.ts:392](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L392)
658
+ Defined in: [types.ts:808](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L808)
581
659
 
582
660
  Definition of a message publisher.
583
661
 
@@ -591,7 +669,7 @@ algorithm when calling the publish method.
591
669
 
592
670
  | Name | Type | Description | Defined in |
593
671
  | ------ | ------ | ------ | ------ |
594
- | `message` | `TMessage` | The message definition including the payload schema | [types.ts:394](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L394) |
672
+ | `message` | `TMessage` | The message definition including the payload schema | [types.ts:810](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L810) |
595
673
 
596
674
  #### Type Parameters
597
675
 
@@ -617,7 +695,7 @@ const publisher: PublisherDefinition = {
617
695
  type PublisherFirstResult<TMessage, TPublisher> = object;
618
696
  ```
619
697
 
620
- Defined in: [builder.ts:773](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L773)
698
+ Defined in: [builder.ts:998](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L998)
621
699
 
622
700
  Publisher-first builder result for fanout and direct exchanges.
623
701
 
@@ -638,8 +716,8 @@ emit events without knowing which queues will consume them.
638
716
 
639
717
  | Property | Type | Description | Defined in |
640
718
  | ------ | ------ | ------ | ------ |
641
- | <a id="createconsumer"></a> `createConsumer` | (`queue`) => `object` | Create a consumer that receives messages from this publisher. The consumer will automatically use the same message schema and a binding will be created with the same routing key. | [builder.ts:787](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L787) |
642
- | <a id="publisher"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:778](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L778) |
719
+ | <a id="createconsumer"></a> `createConsumer` | (`queue`) => `object` | Create a consumer that receives messages from this publisher. The consumer will automatically use the same message schema and a binding will be created with the same routing key. | [builder.ts:1012](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1012) |
720
+ | <a id="publisher"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:1003](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1003) |
643
721
 
644
722
  ***
645
723
 
@@ -649,7 +727,7 @@ emit events without knowing which queues will consume them.
649
727
  type PublisherFirstResultWithRoutingKey<TMessage, TPublisher, TRoutingKey> = object;
650
728
  ```
651
729
 
652
- Defined in: [builder.ts:925](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L925)
730
+ Defined in: [builder.ts:1150](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1150)
653
731
 
654
732
  Publisher-first builder result for topic exchanges.
655
733
 
@@ -668,8 +746,8 @@ to create consumers that can use routing key patterns matching the publisher's k
668
746
 
669
747
  | Property | Type | Description | Defined in |
670
748
  | ------ | ------ | ------ | ------ |
671
- | <a id="createconsumer-1"></a> `createConsumer` | \<`TConsumerRoutingKey`\>(`queue`, `routingKey?`) => `object` | Create a consumer that receives messages from this publisher. For topic exchanges, the routing key pattern can be specified for the binding. | [builder.ts:940](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L940) |
672
- | <a id="publisher-1"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:931](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L931) |
749
+ | <a id="createconsumer-1"></a> `createConsumer` | \<`TConsumerRoutingKey`\>(`queue`, `routingKey?`) => `object` | Create a consumer that receives messages from this publisher. For topic exchanges, the routing key pattern can be specified for the binding. | [builder.ts:1165](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1165) |
750
+ | <a id="publisher-1"></a> `publisher` | `TPublisher` | The publisher definition | [builder.ts:1156](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1156) |
673
751
 
674
752
  ***
675
753
 
@@ -688,7 +766,7 @@ type QueueBindingDefinition = object &
688
766
  };
689
767
  ```
690
768
 
691
- Defined in: [types.ts:286](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L286)
769
+ Defined in: [types.ts:702](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L702)
692
770
 
693
771
  Binding between a queue and an exchange.
694
772
 
@@ -700,35 +778,222 @@ For fanout exchanges, no routing key is needed as all messages are broadcast.
700
778
 
701
779
  | Name | Type | Description | Defined in |
702
780
  | ------ | ------ | ------ | ------ |
703
- | `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. Can be used for advanced routing scenarios with the headers exchange type. | [types.ts:297](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L297) |
704
- | `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:291](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L291) |
705
- | `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:288](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L288) |
781
+ | `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for the binding. Can be used for advanced routing scenarios with the headers exchange type. | [types.ts:713](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L713) |
782
+ | `queue` | [`QueueDefinition`](#queuedefinition) | The queue that will receive messages | [types.ts:707](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L707) |
783
+ | `type` | `"queue"` | Discriminator indicating this is a queue-to-exchange binding | [types.ts:704](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L704) |
706
784
 
707
785
  ***
708
786
 
709
787
  ### QueueDefinition
710
788
 
711
789
  ```ts
712
- type QueueDefinition = object;
790
+ type QueueDefinition =
791
+ | QuorumQueueDefinition
792
+ | ClassicQueueDefinition;
713
793
  ```
714
794
 
715
- Defined in: [types.ts:174](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L174)
795
+ Defined in: [types.ts:600](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L600)
716
796
 
717
797
  Definition of an AMQP queue.
718
798
 
719
- A queue stores messages until they are consumed by workers. Queues are bound to exchanges
720
- to receive messages based on routing rules.
799
+ A discriminated union based on queue type:
800
+ - `QuorumQueueDefinition`: For quorum queues (type: "quorum")
801
+ - `ClassicQueueDefinition`: For classic queues (type: "classic")
802
+
803
+ Use `queue.type` as the discriminator to narrow the type.
804
+
805
+ ***
806
+
807
+ ### QueueEntry
808
+
809
+ ```ts
810
+ type QueueEntry =
811
+ | QueueDefinition
812
+ | QueueWithTtlBackoffInfrastructure;
813
+ ```
814
+
815
+ Defined in: [types.ts:658](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L658)
816
+
817
+ A queue entry that can be passed to `defineContract`.
818
+
819
+ Can be either a plain queue definition or a queue with TTL-backoff infrastructure.
820
+
821
+ ***
822
+
823
+ ### QueueType
824
+
825
+ ```ts
826
+ type QueueType = "quorum" | "classic";
827
+ ```
828
+
829
+ Defined in: [types.ts:137](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L137)
830
+
831
+ Supported queue types in RabbitMQ.
832
+
833
+ - `quorum`: Quorum queues (default, recommended) - Provide better durability and high-availability
834
+ using the Raft consensus algorithm. Best for most production use cases.
835
+ - `classic`: Classic queues - The traditional RabbitMQ queue type. Use only when you need
836
+ specific features not supported by quorum queues (e.g., non-durable queues, priority queues).
837
+
838
+ Note: Quorum queues require `durable: true` and do not support `exclusive: true`.
839
+ When using quorum queues, `durable` is automatically set to `true`.
840
+
841
+ #### See
842
+
843
+ https://www.rabbitmq.com/docs/quorum-queues
844
+
845
+ #### Example
846
+
847
+ ```typescript
848
+ // Create a quorum queue (default, recommended)
849
+ const orderQueue = defineQueue('order-processing', {
850
+ type: 'quorum', // This is the default
851
+ });
852
+
853
+ // Create a classic queue (for special cases)
854
+ const tempQueue = defineQueue('temp-queue', {
855
+ type: 'classic',
856
+ durable: false, // Only supported with classic queues
857
+ });
858
+ ```
859
+
860
+ ***
861
+
862
+ ### QueueWithTtlBackoffInfrastructure
863
+
864
+ ```ts
865
+ type QueueWithTtlBackoffInfrastructure = object;
866
+ ```
867
+
868
+ Defined in: [types.ts:625](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L625)
869
+
870
+ A queue with automatically generated TTL-backoff retry infrastructure.
871
+
872
+ This type is returned by `defineQueue` when TTL-backoff retry is configured
873
+ with a dead letter exchange. When passed to `defineContract`, the wait queue
874
+ and bindings are automatically added to the contract.
875
+
876
+ #### Example
877
+
878
+ ```typescript
879
+ const dlx = defineExchange('orders-dlx', 'direct', { durable: true });
880
+ const queue = defineQueue('order-processing', {
881
+ deadLetter: { exchange: dlx },
882
+ retry: { mode: 'ttl-backoff', maxRetries: 5 },
883
+ });
884
+ // queue is QueueWithTtlBackoffInfrastructure
885
+
886
+ const contract = defineContract({
887
+ exchanges: { dlx },
888
+ queues: { orderProcessing: queue }, // Automatically adds wait queue
889
+ // ... bindings are automatically generated
890
+ });
891
+ ```
892
+
893
+ #### Properties
894
+
895
+ | Property | Type | Description | Defined in |
896
+ | ------ | ------ | ------ | ------ |
897
+ | <a id="mainqueueretrybinding"></a> `mainQueueRetryBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes retried messages back to the main queue. | [types.ts:650](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L650) |
898
+ | <a id="queue-1"></a> `queue` | [`QueueDefinition`](#queuedefinition) | The main queue definition. | [types.ts:635](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L635) |
899
+ | <a id="waitqueue"></a> `waitQueue` | [`QueueDefinition`](#queuedefinition) | The wait queue for holding messages during backoff delay. | [types.ts:640](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L640) |
900
+ | <a id="waitqueuebinding"></a> `waitQueueBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes failed messages to the wait queue. | [types.ts:645](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L645) |
901
+
902
+ ***
903
+
904
+ ### QuorumNativeRetryOptions
905
+
906
+ ```ts
907
+ type QuorumNativeRetryOptions = object;
908
+ ```
909
+
910
+ Defined in: [types.ts:72](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L72)
911
+
912
+ Quorum-Native retry options using RabbitMQ's native delivery limit feature.
913
+
914
+ Uses quorum queue's `x-delivery-limit` feature. Messages are requeued immediately
915
+ with `nack(requeue=true)`, and RabbitMQ tracks delivery count via `x-delivery-count`
916
+ header. When the count exceeds the queue's `deliveryLimit`, the message is
917
+ automatically dead-lettered.
918
+
919
+ **Benefits:** Simpler architecture, no wait queues needed, no head-of-queue blocking.
920
+ **Limitation:** Immediate retries only (no exponential backoff).
921
+
922
+ #### See
923
+
924
+ https://www.rabbitmq.com/docs/quorum-queues#poison-message-handling
721
925
 
722
926
  #### Properties
723
927
 
724
928
  | Property | Type | Description | Defined in |
725
929
  | ------ | ------ | ------ | ------ |
726
- | <a id="arguments-1"></a> `arguments?` | `Record`\<`string`, `unknown`\> | Additional AMQP arguments for advanced configuration. Common arguments include: - `x-message-ttl`: Message time-to-live in milliseconds - `x-expires`: Queue expiration time in milliseconds - `x-max-length`: Maximum number of messages in the queue - `x-max-length-bytes`: Maximum size of the queue in bytes - `x-max-priority`: Maximum priority level for priority queues Note: When using the `deadLetter` property, the `x-dead-letter-exchange` and `x-dead-letter-routing-key` arguments are automatically set and should not be specified in this arguments object. **Example** `{ 'x-message-ttl': 86400000, // 24 hours 'x-max-priority': 10 }` | [types.ts:241](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L241) |
727
- | <a id="autodelete-1"></a> `autoDelete?` | `boolean` | If true, the queue is deleted when the last consumer unsubscribes. **Default** `false` | [types.ts:197](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L197) |
728
- | <a id="deadletter"></a> `deadLetter?` | [`DeadLetterConfig`](#deadletterconfig) | Dead letter configuration for handling failed or rejected messages. When configured, messages that are rejected, expire, or exceed queue limits will be automatically forwarded to the specified dead letter exchange. **Example** `const dlx = defineExchange('orders-dlx', 'topic', { durable: true }); const queue = defineQueue('order-processing', { durable: true, deadLetter: { exchange: dlx, routingKey: 'order.failed' } });` | [types.ts:217](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L217) |
729
- | <a id="durable-1"></a> `durable?` | `boolean` | If true, the queue survives broker restarts. Durable queues are persisted to disk. **Default** `false` | [types.ts:184](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L184) |
730
- | <a id="exclusive"></a> `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. **Default** `false` | [types.ts:191](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L191) |
731
- | <a id="name-1"></a> `name` | `string` | The name of the queue. Must be unique within the RabbitMQ virtual host. | [types.ts:178](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L178) |
930
+ | <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/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L77) |
931
+
932
+ ***
933
+
934
+ ### QuorumQueueDefinition
935
+
936
+ ```ts
937
+ type QuorumQueueDefinition = BaseQueueDefinition & object;
938
+ ```
939
+
940
+ Defined in: [types.ts:516](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L516)
941
+
942
+ Definition of a quorum queue.
943
+
944
+ Quorum queues provide better durability and high-availability using the Raft consensus algorithm.
945
+ They support native retry handling via `deliveryLimit` and both TTL-backoff and quorum-native retry modes.
946
+
947
+ #### Type Declaration
948
+
949
+ | Name | Type | Description | Defined in |
950
+ | ------ | ------ | ------ | ------ |
951
+ | `deliveryLimit?` | `number` | Maximum number of delivery attempts before the message is dead-lettered. This is a quorum queue-specific feature. When a message is rejected (nacked) and requeued, RabbitMQ increments the `x-delivery-count` header. When this count reaches the delivery limit, the message is automatically dead-lettered (if DLX is configured) or dropped. **Minimum** 1 - Must be a positive integer (1 or greater) **See** https://www.rabbitmq.com/docs/quorum-queues#poison-message-handling | [types.ts:546](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L546) |
952
+ | `exclusive?` | `never` | Quorum queues do not support exclusive mode. Use type: 'classic' if you need exclusive queues. | [types.ts:526](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L526) |
953
+ | `maxPriority?` | `never` | Quorum queues do not support priority queues. Use type: 'classic' if you need priority queues. | [types.ts:532](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L532) |
954
+ | `retry?` | \| [`TtlBackoffRetryOptions`](#ttlbackoffretryoptions) \| [`QuorumNativeRetryOptions`](#quorumnativeretryoptions) | Retry configuration for handling failed message processing. Quorum queues support both: - `ttl-backoff`: Uses wait queues with exponential backoff - `quorum-native`: Uses RabbitMQ's native delivery limit feature | [types.ts:555](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L555) |
955
+ | `type` | `"quorum"` | Queue type discriminator: quorum queue. | [types.ts:520](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L520) |
956
+
957
+ ***
958
+
959
+ ### QuorumQueueOptions
960
+
961
+ ```ts
962
+ type QuorumQueueOptions = BaseQueueOptions & object;
963
+ ```
964
+
965
+ Defined in: [types.ts:188](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L188)
966
+
967
+ Options for creating a quorum queue.
968
+
969
+ Quorum queues do not support:
970
+ - `exclusive` - Use classic queues for exclusive access
971
+ - `maxPriority` - Use classic queues for priority queues
972
+
973
+ Quorum queues provide native retry support via `deliveryLimit`:
974
+ - RabbitMQ tracks delivery count automatically via `x-delivery-count` header
975
+ - When the limit is exceeded, messages are dead-lettered (if DLX is configured)
976
+ - This is simpler than TTL-based retry and avoids head-of-queue blocking issues
977
+
978
+ #### Type Declaration
979
+
980
+ | Name | Type | Description | Defined in |
981
+ | ------ | ------ | ------ | ------ |
982
+ | `deliveryLimit?` | `number` | Maximum number of delivery attempts before the message is dead-lettered. When a message is rejected (nacked) and requeued, RabbitMQ increments the `x-delivery-count` header. When this count reaches the delivery limit, the message is automatically dead-lettered (if DLX is configured) or dropped. This is a quorum queue-specific feature that provides native retry handling without the complexity of TTL-based wait queues. **Benefits over TTL-based retry:** - Simpler architecture (no wait queues needed) - No head-of-queue blocking issues (TTL only works at queue head) - Native RabbitMQ feature with atomic guarantees **Minimum** 1 - Must be a positive integer (1 or greater) **See** https://www.rabbitmq.com/docs/quorum-queues#poison-message-handling **Example** `const orderQueue = defineQueue('order-processing', { type: 'quorum', deliveryLimit: 5, // Allow up to 5 delivery attempts deadLetter: { exchange: dlx, routingKey: 'order.failed', }, });` | [types.ts:237](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L237) |
983
+ | `exclusive?` | `never` | Quorum queues do not support exclusive mode. Use type: 'classic' if you need exclusive queues. | [types.ts:198](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L198) |
984
+ | `maxPriority?` | `never` | Quorum queues do not support priority queues. Use type: 'classic' if you need priority queues. | [types.ts:204](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L204) |
985
+ | `retry?` | \| [`TtlBackoffRetryOptions`](#ttlbackoffretryoptions) \| [`QuorumNativeRetryOptions`](#quorumnativeretryoptions) | Retry configuration for handling failed message processing. Determines how the worker handles retries for consumers using this queue: - `"ttl-backoff"` (default): Uses wait queues with exponential backoff - `"quorum-native"`: Uses RabbitMQ's native delivery limit feature When using `"ttl-backoff"` mode, the core package will automatically create a wait queue (`{queueName}-wait`) and the necessary bindings. **Example** `// TTL-backoff mode with custom options const orderQueue = defineQueue('order-processing', { type: 'quorum', deadLetter: { exchange: dlx }, retry: { mode: 'ttl-backoff', maxRetries: 5, initialDelayMs: 1000, maxDelayMs: 30000, }, }); // Quorum-native mode const orderQueue = defineQueue('order-processing', { type: 'quorum', deliveryLimit: 5, deadLetter: { exchange: dlx }, retry: { mode: 'quorum-native' }, });` | [types.ts:272](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L272) |
986
+ | `type?` | `"quorum"` | Queue type: quorum (default, recommended) | [types.ts:192](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L192) |
987
+
988
+ #### Example
989
+
990
+ ```typescript
991
+ const orderQueue = defineQueue('orders', {
992
+ type: 'quorum',
993
+ deadLetter: { exchange: dlx },
994
+ deliveryLimit: 3, // Message dead-lettered after 3 delivery attempts
995
+ });
996
+ ```
732
997
 
733
998
  ***
734
999
 
@@ -738,7 +1003,7 @@ to receive messages based on routing rules.
738
1003
  type RoutingKey<S> = S extends "" ? never : S extends `${string}*${string}` | `${string}#${string}` ? never : S;
739
1004
  ```
740
1005
 
741
- Defined in: [builder.ts:817](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L817)
1006
+ Defined in: [builder.ts:1042](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1042)
742
1007
 
743
1008
  Type-safe routing key that validates basic format.
744
1009
 
@@ -772,7 +1037,7 @@ type Invalid2 = RoutingKey<"">; // never (empty string)
772
1037
  type TopicExchangeDefinition = BaseExchangeDefinition & object;
773
1038
  ```
774
1039
 
775
- Defined in: [types.ts:133](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L133)
1040
+ Defined in: [types.ts:433](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L433)
776
1041
 
777
1042
  A topic exchange definition.
778
1043
 
@@ -786,7 +1051,7 @@ Words are separated by dots (e.g., `order.created.high-value`).
786
1051
 
787
1052
  | Name | Type | Defined in |
788
1053
  | ------ | ------ | ------ |
789
- | `type` | `"topic"` | [types.ts:134](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/types.ts#L134) |
1054
+ | `type` | `"topic"` | [types.ts:434](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L434) |
790
1055
 
791
1056
  #### Example
792
1057
 
@@ -797,6 +1062,57 @@ const ordersExchange: TopicExchangeDefinition = defineExchange('orders', 'topic'
797
1062
  // Can be bound with patterns like 'order.*' or 'order.#'
798
1063
  ```
799
1064
 
1065
+ ***
1066
+
1067
+ ### TtlBackoffRetryInfrastructure
1068
+
1069
+ ```ts
1070
+ type TtlBackoffRetryInfrastructure = object;
1071
+ ```
1072
+
1073
+ Defined in: [builder.ts:1760](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1760)
1074
+
1075
+ Result type for TTL-backoff retry infrastructure builder.
1076
+
1077
+ Contains the wait queue and bindings needed for TTL-backoff retry.
1078
+
1079
+ #### Properties
1080
+
1081
+ | Property | Type | Description | Defined in |
1082
+ | ------ | ------ | ------ | ------ |
1083
+ | <a id="mainqueueretrybinding-1"></a> `mainQueueRetryBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes retried messages back to the main queue. | [builder.ts:1773](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1773) |
1084
+ | <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.ts:1765](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1765) |
1085
+ | <a id="waitqueuebinding-1"></a> `waitQueueBinding` | [`QueueBindingDefinition`](#queuebindingdefinition) | Binding that routes failed messages to the wait queue. | [builder.ts:1769](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1769) |
1086
+
1087
+ ***
1088
+
1089
+ ### TtlBackoffRetryOptions
1090
+
1091
+ ```ts
1092
+ type TtlBackoffRetryOptions = object;
1093
+ ```
1094
+
1095
+ Defined in: [types.ts:27](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L27)
1096
+
1097
+ TTL-Backoff retry options for exponential backoff with configurable delays.
1098
+
1099
+ Uses TTL + wait queue pattern. Messages are published to a wait queue with
1100
+ per-message TTL, then dead-lettered back to the main queue after the TTL expires.
1101
+
1102
+ **Benefits:** Configurable delays with exponential backoff and jitter.
1103
+ **Limitation:** More complex, potential head-of-queue blocking with mixed TTLs.
1104
+
1105
+ #### Properties
1106
+
1107
+ | Property | Type | Description | Defined in |
1108
+ | ------ | ------ | ------ | ------ |
1109
+ | <a id="backoffmultiplier"></a> `backoffMultiplier?` | `number` | Exponential backoff multiplier. **Default** `2` | [types.ts:51](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L51) |
1110
+ | <a id="initialdelayms"></a> `initialDelayMs?` | `number` | Initial delay in ms before first retry. **Default** `1000` | [types.ts:41](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L41) |
1111
+ | <a id="jitter"></a> `jitter?` | `boolean` | Add jitter to prevent thundering herd. **Default** `true` | [types.ts:56](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L56) |
1112
+ | <a id="maxdelayms"></a> `maxDelayMs?` | `number` | Maximum delay in ms between retries. **Default** `30000` | [types.ts:46](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L46) |
1113
+ | <a id="maxretries"></a> `maxRetries?` | `number` | Maximum retry attempts before sending to DLQ. **Default** `3` | [types.ts:36](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L36) |
1114
+ | <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/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/types.ts#L31) |
1115
+
800
1116
  ## Functions
801
1117
 
802
1118
  ### defineConsumer()
@@ -808,7 +1124,7 @@ function defineConsumer<TMessage>(
808
1124
  options?): ConsumerDefinition<TMessage>;
809
1125
  ```
810
1126
 
811
- Defined in: [builder.ts:634](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L634)
1127
+ Defined in: [builder.ts:782](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L782)
812
1128
 
813
1129
  Define a message consumer.
814
1130
 
@@ -828,7 +1144,7 @@ with this consumer, it will process messages from the queue according to the sch
828
1144
 
829
1145
  | Parameter | Type | Description |
830
1146
  | ------ | ------ | ------ |
831
- | `queue` | [`QueueDefinition`](#queuedefinition) | The queue definition to consume from |
1147
+ | `queue` | [`QueueEntry`](#queueentry) | The queue definition to consume from |
832
1148
  | `message` | `TMessage` | The message definition with payload schema |
833
1149
  | `options?` | `Omit`\<[`ConsumerDefinition`](#consumerdefinition)\<`TMessage`\>, `"queue"` \| `"message"`\> | Optional consumer configuration |
834
1150
 
@@ -875,7 +1191,7 @@ const processOrderConsumer = defineConsumer(orderQueue, orderMessage);
875
1191
  function defineContract<TContract>(definition): TContract;
876
1192
  ```
877
1193
 
878
- Defined in: [builder.ts:715](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L715)
1194
+ Defined in: [builder.ts:863](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L863)
879
1195
 
880
1196
  Define an AMQP contract.
881
1197
 
@@ -964,7 +1280,7 @@ export const contract = defineContract({
964
1280
  function defineMessage<TPayload, THeaders>(payload, options?): MessageDefinition<TPayload, THeaders>;
965
1281
  ```
966
1282
 
967
- Defined in: [builder.ts:236](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L236)
1283
+ Defined in: [builder.ts:381](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L381)
968
1284
 
969
1285
  Define a message definition with payload and optional headers/metadata.
970
1286
 
@@ -1022,47 +1338,46 @@ const orderMessage = defineMessage(
1022
1338
  ### defineQueue()
1023
1339
 
1024
1340
  ```ts
1025
- function defineQueue(name, options?): QueueDefinition;
1341
+ function defineQueue(name, options?):
1342
+ | QueueDefinition
1343
+ | QueueWithTtlBackoffInfrastructure;
1026
1344
  ```
1027
1345
 
1028
- Defined in: [builder.ts:170](https://github.com/btravers/amqp-contract/blob/f058a24938d9644a82812e57d7995cb683cfd6b5/packages/contract/src/builder.ts#L170)
1346
+ Defined in: [builder.ts:198](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L198)
1029
1347
 
1030
1348
  Define an AMQP queue.
1031
1349
 
1032
1350
  A queue stores messages until they are consumed by workers. Queues can be bound to exchanges
1033
1351
  to receive messages based on routing rules.
1034
1352
 
1353
+ By default, queues are created as quorum queues which provide better durability and
1354
+ high-availability. Use `type: 'classic'` for special cases like non-durable queues
1355
+ or priority queues.
1356
+
1035
1357
  #### Parameters
1036
1358
 
1037
1359
  | Parameter | Type | Description |
1038
1360
  | ------ | ------ | ------ |
1039
1361
  | `name` | `string` | The name of the queue |
1040
- | `options?` | `Omit`\<[`QueueDefinition`](#queuedefinition), `"name"`\> & `object` | Optional queue configuration |
1362
+ | `options?` | [`DefineQueueOptions`](#definequeueoptions) | Optional queue configuration |
1041
1363
 
1042
1364
  #### Returns
1043
1365
 
1044
- [`QueueDefinition`](#queuedefinition)
1366
+ \| [`QueueDefinition`](#queuedefinition)
1367
+ \| [`QueueWithTtlBackoffInfrastructure`](#queuewithttlbackoffinfrastructure)
1045
1368
 
1046
1369
  A queue definition
1047
1370
 
1048
1371
  #### Example
1049
1372
 
1050
1373
  ```typescript
1051
- // Basic queue
1052
- const orderQueue = defineQueue('order-processing', {
1053
- durable: true,
1054
- });
1055
-
1056
- // Priority queue with max priority of 10
1057
- const taskQueue = defineQueue('urgent-tasks', {
1058
- durable: true,
1059
- maxPriority: 10,
1060
- });
1374
+ // Quorum queue (default, recommended for production)
1375
+ const orderQueue = defineQueue('order-processing');
1061
1376
 
1062
- // Queue with dead letter exchange
1377
+ // Explicit quorum queue with dead letter exchange
1063
1378
  const dlx = defineExchange('orders-dlx', 'topic', { durable: true });
1064
1379
  const orderQueueWithDLX = defineQueue('order-processing', {
1065
- durable: true,
1380
+ type: 'quorum',
1066
1381
  deadLetter: {
1067
1382
  exchange: dlx,
1068
1383
  routingKey: 'order.failed'
@@ -1071,4 +1386,131 @@ const orderQueueWithDLX = defineQueue('order-processing', {
1071
1386
  'x-message-ttl': 86400000, // 24 hours
1072
1387
  }
1073
1388
  });
1389
+
1390
+ // Classic queue (for special cases)
1391
+ const tempQueue = defineQueue('temp-queue', {
1392
+ type: 'classic',
1393
+ durable: false,
1394
+ autoDelete: true,
1395
+ });
1396
+
1397
+ // Priority queue (requires classic type)
1398
+ const taskQueue = defineQueue('urgent-tasks', {
1399
+ type: 'classic',
1400
+ durable: true,
1401
+ maxPriority: 10,
1402
+ });
1403
+
1404
+ // Queue with TTL-backoff retry (returns infrastructure automatically)
1405
+ const dlx = defineExchange('orders-dlx', 'direct', { durable: true });
1406
+ const orderQueue = defineQueue('order-processing', {
1407
+ deadLetter: { exchange: dlx },
1408
+ retry: { mode: 'ttl-backoff', maxRetries: 5 },
1409
+ });
1410
+ // orderQueue is QueueWithTtlBackoffInfrastructure, pass directly to defineContract
1411
+ ```
1412
+
1413
+ ***
1414
+
1415
+ ### defineTtlBackoffRetryInfrastructure()
1416
+
1417
+ ```ts
1418
+ function defineTtlBackoffRetryInfrastructure(queueEntry, options?): TtlBackoffRetryInfrastructure;
1419
+ ```
1420
+
1421
+ Defined in: [builder.ts:1826](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L1826)
1422
+
1423
+ Create TTL-backoff retry infrastructure for a queue.
1424
+
1425
+ This builder helper generates the wait queue and bindings needed for TTL-backoff retry.
1426
+ The generated infrastructure can be spread into a contract definition.
1427
+
1428
+ TTL-backoff retry works by:
1429
+ 1. Failed messages are sent to the DLX with routing key `{queueName}-wait`
1430
+ 2. The wait queue receives these messages and holds them for a TTL period
1431
+ 3. After TTL expires, messages are dead-lettered back to the DLX with routing key `{queueName}`
1432
+ 4. The main queue receives the retried message via its binding to the DLX
1433
+
1434
+ #### Parameters
1435
+
1436
+ | Parameter | Type | Description |
1437
+ | ------ | ------ | ------ |
1438
+ | `queueEntry` | [`QueueEntry`](#queueentry) | - |
1439
+ | `options?` | \{ `waitQueueDurable?`: `boolean`; \} | Optional configuration for the wait queue |
1440
+ | `options.waitQueueDurable?` | `boolean` | Whether the wait queue should be durable (default: same as main queue) |
1441
+
1442
+ #### Returns
1443
+
1444
+ [`TtlBackoffRetryInfrastructure`](#ttlbackoffretryinfrastructure)
1445
+
1446
+ TTL-backoff retry infrastructure containing wait queue and bindings
1447
+
1448
+ #### Throws
1449
+
1450
+ If the queue does not have a dead letter exchange configured
1451
+
1452
+ #### Example
1453
+
1454
+ ```typescript
1455
+ const dlx = defineExchange('orders-dlx', 'direct', { durable: true });
1456
+ const orderQueue = defineQueue('order-processing', {
1457
+ type: 'quorum',
1458
+ deadLetter: { exchange: dlx },
1459
+ retry: {
1460
+ mode: 'ttl-backoff',
1461
+ maxRetries: 5,
1462
+ initialDelayMs: 1000,
1463
+ },
1464
+ });
1465
+
1466
+ // Generate TTL-backoff infrastructure
1467
+ const retryInfra = defineTtlBackoffRetryInfrastructure(orderQueue);
1468
+
1469
+ // Spread into contract
1470
+ const contract = defineContract({
1471
+ exchanges: { dlx },
1472
+ queues: {
1473
+ orderProcessing: orderQueue,
1474
+ orderProcessingWait: retryInfra.waitQueue,
1475
+ },
1476
+ bindings: {
1477
+ ...// your other bindings
1478
+ orderWaitBinding: retryInfra.waitQueueBinding,
1479
+ orderRetryBinding: retryInfra.mainQueueRetryBinding,
1480
+ },
1481
+ // ... publishers and consumers
1482
+ });
1483
+ ```
1484
+
1485
+ ***
1486
+
1487
+ ### extractQueue()
1488
+
1489
+ ```ts
1490
+ function extractQueue(entry): QueueDefinition;
1491
+ ```
1492
+
1493
+ Defined in: [builder.ts:939](https://github.com/btravers/amqp-contract/blob/ed05e43c04fa526b751d45622ccc1ac53b2e96f9/packages/contract/src/builder.ts#L939)
1494
+
1495
+ Extract the plain QueueDefinition from a QueueEntry.
1496
+ If the entry is a QueueWithTtlBackoffInfrastructure, returns the inner queue.
1497
+ Otherwise, returns the entry as-is.
1498
+
1499
+ #### Parameters
1500
+
1501
+ | Parameter | Type | Description |
1502
+ | ------ | ------ | ------ |
1503
+ | `entry` | [`QueueEntry`](#queueentry) | The queue entry (either plain QueueDefinition or QueueWithTtlBackoffInfrastructure) |
1504
+
1505
+ #### Returns
1506
+
1507
+ [`QueueDefinition`](#queuedefinition)
1508
+
1509
+ The plain QueueDefinition
1510
+
1511
+ #### Example
1512
+
1513
+ ```typescript
1514
+ const queue = defineQueue('orders', { retry: { mode: 'ttl-backoff' }, deadLetter: { exchange: dlx } });
1515
+ const plainQueue = extractQueue(queue); // Returns the inner QueueDefinition
1074
1516
  ```