@amqp-contract/worker 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 +6 -7
- package/dist/index.cjs +415 -291
- package/dist/index.d.cts +123 -149
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +122 -148
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +409 -284
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +90 -115
- package/package.json +29 -29
package/README.md
CHANGED
|
@@ -20,9 +20,8 @@ pnpm add @amqp-contract/worker
|
|
|
20
20
|
|
|
21
21
|
- ✅ **Type-safe message consumption** — Handlers are fully typed based on your contract
|
|
22
22
|
- ✅ **Automatic validation** — Messages are validated before reaching your handlers
|
|
23
|
-
- ✅ **Automatic retry
|
|
23
|
+
- ✅ **Automatic retry mechanism** — Built-in immediate or exponential backoff retry mechanisms
|
|
24
24
|
- ✅ **Prefetch configuration** — Control message flow with per-consumer prefetch settings
|
|
25
|
-
- ✅ **Batch processing** — Process multiple messages at once for better throughput
|
|
26
25
|
- ✅ **Automatic reconnection** — Built-in connection management with failover support
|
|
27
26
|
|
|
28
27
|
## Usage
|
|
@@ -68,16 +67,16 @@ const worker = await TypedAmqpWorker.create({
|
|
|
68
67
|
|
|
69
68
|
### Advanced Features
|
|
70
69
|
|
|
71
|
-
For advanced features like prefetch configuration
|
|
70
|
+
For advanced features like prefetch configuration and **automatic retry**, see the [Worker Usage Guide](https://btravers.github.io/amqp-contract/guide/worker-usage).
|
|
72
71
|
|
|
73
|
-
#### Retry
|
|
72
|
+
#### Retry configuration
|
|
74
73
|
|
|
75
74
|
Retry is configured at the queue level in your contract definition. Add `retry` to your queue definition:
|
|
76
75
|
|
|
77
76
|
```typescript
|
|
78
77
|
import { defineQueue, defineExchange, defineContract } from "@amqp-contract/contract";
|
|
79
78
|
|
|
80
|
-
const dlx = defineExchange("orders-dlx"
|
|
79
|
+
const dlx = defineExchange("orders-dlx");
|
|
81
80
|
|
|
82
81
|
// Configure retry at queue level
|
|
83
82
|
const orderQueue = defineQueue("order-processing", {
|
|
@@ -112,7 +111,7 @@ const worker = await TypedAmqpWorker.create({
|
|
|
112
111
|
});
|
|
113
112
|
```
|
|
114
113
|
|
|
115
|
-
|
|
114
|
+
See the [Error Handling and Retry](https://btravers.github.io/amqp-contract/guide/worker-usage#error-handling-and-retry) section in the guide for complete details.
|
|
116
115
|
|
|
117
116
|
## Defining Handlers Externally
|
|
118
117
|
|
|
@@ -148,7 +147,7 @@ Worker defines error classes:
|
|
|
148
147
|
- `TechnicalError` - Runtime failures (parsing, processing)
|
|
149
148
|
- `MessageValidationError` - Message fails schema validation
|
|
150
149
|
- `RetryableError` - Signals that the error is transient and should be retried
|
|
151
|
-
- `NonRetryableError` - Signals permanent failure, message
|
|
150
|
+
- `NonRetryableError` - Signals permanent failure, message is sent to DLQ (if configured) or dropped
|
|
152
151
|
|
|
153
152
|
## API
|
|
154
153
|
|