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
> Unified event-driven architecture library with Kafka, RabbitMQ, PostgreSQL (LISTEN/NOTIFY + outbox), and Spring Application Events support.
8
+
> Reactive, transport-agnostic event-driven architecture core for Spring Boot — one publisher/consumer API with annotation-driven publishing, declarative listeners, and pluggable Kafka, RabbitMQ and PostgreSQL adapters.
9
9
10
10
---
11
11
@@ -23,92 +23,191 @@
23
23
24
24
## Overview
25
25
26
-
Firefly Framework EDA provides a standardized messaging abstraction for event-driven architectures, supporting multiple broker implementations through a unified publisher/consumer API. It enables reactive event publishing and consumption with built-in support for Apache Kafka, RabbitMQ, PostgreSQL (via `LISTEN`/`NOTIFY` backed by a transactional outbox table), and Spring Application Events as transport mechanisms.
26
+
Firefly Framework EDA is the **core abstraction** for event-driven architectures across the Firefly Framework. It defines a single, reactive publisher/consumer SPI (`EventPublisher`, `EventConsumer`) and a rich annotation model (`@EventPublisher`, `@PublishResult`, `@EventListener`) so application code emits and handles domain events without binding to any particular broker. The same business code runs unchanged whether events flow over Apache Kafka, RabbitMQ, PostgreSQL, or the in-process Spring application event bus.
27
27
28
-
The library features annotation-driven event publishing (`@EventPublisher`, `@PublishResult`), declarative event listeners (`@EventListener`), and a comprehensive set of event filtering, serialization, and error handling capabilities. It includes support for JSON, Avro, and Protobuf message serialization formats.
28
+
This module ships **everything that is broker-independent**: the SPI, the annotation aspects, the `EventPublisherFactory` (which auto-discovers every `EventPublisher` bean on the classpath and selects one by type or priority), the `EventEnvelope` metadata model, pluggable serialization (JSON, Avro, Protobuf), composable event filters, a resilient publisher wrapper (circuit breaker, retry, rate limiter via Resilience4j), a dead-letter-queue handler, plus Actuator health indicators and Micrometer metrics. Out of the box, the core provides a working **Spring Application Events** transport (in-JVM publish/consume) and a `Noop` transport for testing — no external infrastructure required.
29
29
30
-
The resilient publisher wrapper provides circuit breaker integration, while the dead letter queue handler ensures no events are lost during processing failures. Metrics collection and health indicators provide full observability into the messaging infrastructure.
30
+
The concrete broker transports are now **separate adapter modules**. The core discovers them at runtime: add the adapter dependency, enable it in `firefly.eda.*` configuration, and the `EventPublisherFactory` picks it up automatically. The `firefly.eda.default-publisher-type` property (or `PublisherType.AUTO`) selects which transport a publish goes to, with `AUTO` resolving in priority order `KAFKA → RABBITMQ → POSTGRES → APPLICATION_EVENT` based on what is configured and on the classpath.
31
+
32
+
### Transport adapters
33
+
34
+
| Transport | Adapter module | Selected by | Persistence | Ordering |
| Spring Application Events (in-JVM) |**built into this core**|`PublisherType.APPLICATION_EVENT`| no | no |
40
+
| No-op (testing / disabled) |**built into this core**|`PublisherType.NOOP`| no | no |
41
+
42
+
The `firefly.eda.*` configuration schema (including `publishers.kafka.*`, `publishers.rabbitmq.*`, `publishers.postgres.*` and their consumer counterparts) is defined here in the core so it remains stable and consistent regardless of which adapters you install.
- Dead letter queue (DLQ) handling for failed messages
41
-
- Resilient publisher with circuit breaker support
42
-
- Dynamic event listener registration at runtime
43
-
- AMQP admin auto-configuration for RabbitMQ exchanges and queues
44
-
- Transactional outbox table for PostgreSQL with auto-created schema and trigger
45
-
- Custom error handling strategies with metrics and notification handlers
46
-
- Health indicators and metrics for Actuator integration
47
-
- Spring Boot auto-configuration for Kafka, RabbitMQ, and PostgreSQL
46
+
-**Unified reactive SPI** — `EventPublisher` and `EventConsumer` expose `Mono`/`Flux` APIs; one programming model for all transports
47
+
-**Annotation-driven publishing** — `@EventPublisher` (publish a parameter or wrapped method args, `BEFORE`/`AFTER`/`BOTH` execution) and `@PublishResult` (publish the method's return value), both with SpEL `condition`, `key`, `headers`, `destination` and `eventType`
48
+
-**Declarative listeners** — `@EventListener` with `destinations`, `eventTypes` (glob patterns), SpEL `condition`, `priority`, per-listener retry and `errorStrategy`
49
+
-**Pluggable transports** — Kafka, RabbitMQ and PostgreSQL adapters are independent modules; the in-JVM Spring Application Event transport and a `Noop` transport ship in the core
50
+
-**Auto transport selection** — `EventPublisherFactory` discovers all `EventPublisher` beans and resolves `PublisherType.AUTO` in priority order `KAFKA → RABBITMQ → POSTGRES → APPLICATION_EVENT`
51
+
-**Dynamic destination selection** — `getPublisherWithDestination(...)` overrides the default topic/queue/channel at runtime via `DestinationAwarePublisher`
52
+
-**Event envelope pattern** — `EventEnvelope` carries payload plus metadata (event type, destination, headers, timestamps) end to end
53
+
-**Pluggable serialization** — `MessageSerializer` with built-in JSON, Avro and Protobuf implementations (`SerializationFormat`)
54
+
-**Composable filtering** — `EventTypeFilter`, `HeaderEventFilter`, `DestinationEventFilter` and `CompositeEventFilter` implementing a common `EventFilter` SPI
55
+
-**Resilience** — `ResilientEventPublisher` wraps any publisher with Resilience4j circuit breaker, retry and rate limiter (all configurable, opt-in by classpath)
56
+
-**Dead-letter handling** — `DeadLetterQueueHandler` and `DeadLetterQueueEvent` capture messages that exhaust retries
57
+
-**Custom error handling** — `CustomErrorHandler` SPI with a registry and built-in `MetricsErrorHandler` / `NotificationErrorHandler`
58
+
-**Dynamic registration** — `DynamicEventListenerRegistry` registers and removes listeners at runtime
59
+
-**Observability** — `EdaHealthIndicator` for Actuator and `EdaMetrics` for Micrometer, wired through `fireflyframework-observability`
60
+
-**Spring Boot auto-configuration** — `FireflyEdaAutoConfiguration` activates on `firefly.eda.enabled=true` (default) and component-scans the whole module
48
61
49
62
## Requirements
50
63
51
-
- Java 21+
64
+
- Java 21+ (Java 25 recommended)
52
65
- Spring Boot 3.x
53
66
- Maven 3.9+
54
-
- Apache Kafka, RabbitMQ, or PostgreSQL 11+ (depending on chosen transport)
67
+
-A transport adapter for production messaging: an Apache Kafka broker, a RabbitMQ broker, or a PostgreSQL 11+ database (the in-JVM Spring Application Event transport needs no external infrastructure)
55
68
56
69
## Installation
57
70
71
+
Add the EDA core. The version is managed by the Firefly BOM / parent, so you normally omit it:
72
+
58
73
```xml
59
74
<dependency>
60
75
<groupId>org.fireflyframework</groupId>
61
76
<artifactId>fireflyframework-eda</artifactId>
62
-
<version>26.02.07</version>
77
+
<!-- version managed by fireflyframework-bom / fireflyframework-parent -->
78
+
</dependency>
79
+
```
80
+
81
+
To publish/consume over a real broker, add the matching transport adapter alongside the core. For example, for Apache Kafka:
Swap the artifact for `fireflyframework-eda-rabbitmq` or `fireflyframework-eda-postgres` as needed. You can install more than one adapter and route events per transport with `PublisherType`.
92
+
66
93
## Quick Start
67
94
95
+
With only the core on the classpath, events flow over the in-JVM Spring Application Event bus — perfect for a single instance, tests, or local development.
To send the same code over Apache Kafka, add `fireflyframework-eda-kafka` and configure a Kafka publisher (see below) — no code changes required.
151
+
94
152
## Configuration
95
153
154
+
All properties live under the `firefly.eda.*` namespace (see `EdaProperties`). The EDA core is enabled by default; publishers and consumers are **disabled by default** and opt in per transport. A representative configuration:
155
+
96
156
```yaml
97
157
firefly:
98
158
eda:
99
-
enabled: true
100
-
default-publisher-type: AUTO # AUTO chooses KAFKA → RABBITMQ → POSTGRES → APPLICATION_EVENT
101
-
publishers:
159
+
enabled: true # master switch for the whole module (default: true)
160
+
default-publisher-type: AUTO # AUTO | APPLICATION_EVENT | KAFKA | RABBITMQ | POSTGRES | NOOP
161
+
default-connection-id: default # connection key used when none is given
162
+
default-destination: events # destination used when none is specified
| `firefly.eda.publishers.enabled` | `false` | Global opt-in for all publishers. |
272
+
| `firefly.eda.consumer.enabled` | `false` | Global opt-in for all consumers. |
273
+
| `firefly.eda.consumer.group-id` | `firefly-eda` | Default consumer group id (used by group-based transports such as Kafka). |
274
+
| `firefly.eda.resilience.*` | see above | Circuit breaker, retry and rate-limiter settings applied by `ResilientEventPublisher`. |
275
+
276
+
The `kafka.*`, `rabbitmq.*` and `postgres.*` sub-trees are mapped by connection id (the `default` key shown above), letting you define multiple named connections per transport. These keys are recognized by the core's property schema even before the corresponding adapter is installed; the actual transport beans only activate when the matching adapter module is on the classpath and enabled.
168
277
169
278
## Documentation
170
279
171
-
Additional documentation is available in the [docs/](docs/) directory:
280
+
- Framework documentation hub and module catalog: [fireflyframework/fireflyframework](https://github.com/fireflyframework)
281
+
- Transport adapters: [eda-kafka](https://github.com/fireflyframework/fireflyframework-eda-kafka), [eda-rabbitmq](https://github.com/fireflyframework/fireflyframework-eda-rabbitmq), [eda-postgres](https://github.com/fireflyframework/fireflyframework-eda-postgres)
Contributions are welcome. Please read the [CONTRIBUTING.md](CONTRIBUTING.md) guide for details on our code of conduct, development process, and how to submit pull requests.
299
+
Contributions are welcome. Please read the [CONTRIBUTING.md](docs/CONTRIBUTING.md) guide for details on our code of conduct, development process, and how to submit pull requests.
0 commit comments