You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,18 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
8
-
## v2.1.0 - 2025-03-XX
8
+
## v2.1.0 - 2025-04-06
9
9
10
10
### Added
11
11
12
-
-[CAP Queue] Add support for defining successor and failed events of event handlers. See documentation for how to use it.
12
+
-[CAP Queue] Add support for event chaining: register `#succeeded` and `#failed` successor handlers that are automatically triggered based on the outcome of an event handler. See [documentation](https://cap-js-community.github.io/event-queue/use-as-cap-outbox/#event-chaining).
13
+
-[CAP Queue] Add `#done` unconditional successor — fires after every event regardless of success or failure, analogous to a `finally` block. Useful for cleanup that must always run (releasing locks, audit events, etc.).
14
+
-[CAP Queue] Successor handlers (`#succeeded`, `#failed`, `#done`) can be configured independently in the `events` section of the service's `queued` configuration, including event-specific variants (e.g. `orderCreated/#succeeded`).
15
+
-[Telemetry] Add opt-in event queue metrics (`collectEventQueueMetrics`). When enabled together with Redis and an OpenTelemetry MeterProvider, the module publishes `cap.event_queue.jobs.pending`, `cap.event_queue.jobs.in_progress`, and `cap.event_queue.stats.refresh_age` as Observable Gauges, broken down by namespace. See [documentation](https://cap-js-community.github.io/event-queue/telemetry/).
13
16
14
17
## v2.0.5 - 2025-03-10
15
18
16
19
### Added
17
20
18
21
-[CAP Queue] Allow to propagate cds.context properties (e.g. features). This can be configured per event (`cds.env.requires[<SERVICE>].queued.propagateContextProperties = ["features"]`)
19
-
-[Telemetry] Add opt-in event queue metrics (`collectEventQueueMetrics`). When enabled together with Redis and an OpenTelemetry MeterProvider, the module publishes `cap.event_queue.jobs.pending`, `cap.event_queue.jobs.in_progress`, and `cap.event_queue.stats.refresh_age` as Observable Gauges, broken down by namespace. See [documentation](https://cap-js-community.github.io/event-queue/telemetry/).
Copy file name to clipboardExpand all lines: docs/setup/index.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,7 @@ The table includes the parameter name, a description of its purpose, and the def
77
77
| cleanupLocksAndEventsForDev | Deletes all semantic locks and sets all events that are in progress to error during server start. This is used to clean up leftovers from server crashes or restarts during processing. | true | no |
78
78
| insertEventsBeforeCommit | If enabled, this feature allows events (including those for queued services) to be inserted in bulk using the before commit handler. This is performed to improve performance by mass inserting events instead of single insert operations. This can be disabled by the parameter `skipInsertEventsBeforeCommit` in the function publishEvent. | true | yes |
79
79
| enableTelemetry | If enabled, OpenTelemetry traces for all event-queue activities are written. An OpenTelemetry exporter must be configured. | true | yes |
80
+
| collectEventQueueMetrics | If enabled, publishes `cap.event_queue.jobs.pending`, `cap.event_queue.jobs.in_progress`, and `cap.event_queue.stats.refresh_age` as OpenTelemetry Observable Gauges. Requires `enableTelemetry: true`, Redis, and an OpenTelemetry MeterProvider. See [documentation](https://cap-js-community.github.io/event-queue/telemetry/). | false | no |
80
81
| cronTimezone | Determines whether to apply the central `cronTimezone` setting for scheduling events. If set to `true` and the property `utc` is not enabled for the given event, it will use the defined `cronTimezone`. If set to `false`, the event will use UTC or the server's local time, based on the `utc` setting. | null | yes |
81
82
| randomOffsetPeriodicEvents | Specifies the default maximum random offset (in seconds) applied to all periodic events to help stagger their start times and reduce simultaneous execution spikes. This setting is especially useful in multi-tenant environments where many events may be triggered at the same time. The actual offset for each event will be a random number between `0` and this value. Can be overridden per event using the `randomOffset` property. | null | yes |
82
83
| disableRedis | Whether or not to disable Redis. | false | no |
// req.eventQueue.triggerEvent is available here (see below)
444
+
});
445
+
446
+
// Runs on failure — event-specific
447
+
this.on("orderCreated/#failed", async (req) => {
448
+
// req.data.error contains the serialised error message
449
+
});
450
+
451
+
// Runs unconditionally — event-specific
452
+
this.on("orderCreated/#done", async (req) => {
453
+
// always runs; req.data.error is set when the parent failed
454
+
});
455
+
456
+
// Generic fallbacks — run for any event without a dedicated handler
457
+
this.on("#succeeded", async (req) => {
458
+
/* ... */
459
+
});
460
+
this.on("#failed", async (req) => {
461
+
/* ... */
462
+
});
463
+
this.on("#done", async (req) => {
464
+
/* ... */
465
+
});
466
+
}
467
+
}
468
+
```
469
+
470
+
### Passing Data to the Successor
471
+
472
+
Return a `nextData` property from the primary handler to forward arbitrary data to the successor's `req.data`:
473
+
474
+
```javascript
475
+
this.on("orderCreated", async (req) => {
476
+
constorderId=awaitcreateOrder(req.data);
477
+
return {
478
+
status:EventProcessingStatus.Done,
479
+
nextData: { orderId }, // available as req.data.orderId in the successor
480
+
};
481
+
});
482
+
```
483
+
484
+
`nextData` is forwarded to all active successors (`#succeeded`, `#failed`, `#done`). For `#done` this is useful when cleanup logic needs to act on data produced by the primary handler.
485
+
486
+
### Accessing the Trigger Event Context (`req.eventQueue.triggerEvent`)
487
+
488
+
When a successor handler is invoked, `req.eventQueue.triggerEvent` is populated with context from the parent event.
489
+
This gives the successor full visibility into what happened in the previous step.
0 commit comments