atiaomar1978-hub opened a new pull request, #25495: URL: https://github.com/apache/camel/pull/25495
## Description Implements [CAMEL-24377](https://issues.apache.org/jira/browse/CAMEL-24377): structured JSON serialization for `CamelEvent`, similar to the existing `BacklogEventMessage` API used by Error Registry and Backlog Tracer. ### API Added to `org.apache.camel.spi.CamelEvent`: - `Map<String, Object> asJSon()` — structured event metadata as a JSON-compatible map - `String toJSon(int indent)` — pretty-printed JSON string ### Implementation - `CamelEventJsonSupport` in `camel-base` builds JSON for all standard event types (context, route, exchange, step, service, failure) - Abstract event base classes and service failure events delegate to the support class - `EventConsole` now uses `event.asJSon()` instead of ad hoc `toString()` fields ### JSON fields (examples) | Event category | Fields | |----------------|--------| | All events | `type`, `eventClass`, `timestamp`, `message` | | Context | `contextName` | | Route | `routeId`, `routeGroup`, `fromEndpointUri` | | Exchange | `exchangeId`, `fromRouteId`, `routeId` | | Sent/Sending | `endpointUri`, `timeTaken` (sent) | | Failure | `exception` (type, message, stackTrace) | | Redelivery | `attempt`, `exception` | | Step | `stepId` | | Service failure | `service`, `contextName` | ### Tests `CamelEventJsonTest` covers context, exchange failed/sent/failure-handling/redelivery, route reloaded/restarting failure, step failed, and service startup failure events. ```bash ./mvnw -pl core/camel-core -am test -Dtest=CamelEventJsonTest -Dsurefire.failIfNoSpecifiedTests=false ``` ### Documentation Updated `docs/user-manual/modules/ROOT/pages/event-notifier.adoc` with JSON serialization section. ## Tracking - [x] [CAMEL-24377](https://issues.apache.org/jira/browse/CAMEL-24377) ## AI-assisted contributions _AI-generated PR on behalf of atiaomar1978-hub (Cursor Agent)_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
