654894017/cqrs
53.2
Adequate · 20 September 2026
6.9k
lines of production code
Java
primary language
4
measurements over time
What this system is
This system is a CQRS (Command Query Responsibility Segregation) framework built on event sourcing, designed to manage aggregate state through command processing and asynchronous event dispatch. It provides core infrastructure for handling concurrent command execution, local caching, and aggregate recovery, while supporting pluggable event stores (MySQL with sharding) and message brokers (Kafka, RocketMQ). The architecture includes mechanisms for snapshotting, conflict resolution, and distributed locking to ensure data integrity under high concurrency.
How it got here
2021 — CQRS framework restructuring
6 changes.
The project removed an initial CQRS implementation and restructured the build into a multi-module architecture with upgraded dependencies. Core domain models, utilities, and exception handling were refactored to support new patterns like sharding and manual snapshots, while a new SQL schema was introduced for event persistence.
2022 — scalability and extensibility enhancements
5 changes.
The project focused on enhancing the CQRS framework's scalability and extensibility by introducing sharding support for event storage, a custom SPI mechanism for pluggable implementations, and robust distributed locking. Concurrently, the RocketMQ integration was refactored to improve message ordering and reliability, while new utility classes addressed ID generation and conflict handling. These core improvements were demonstrated through new sample applications for goods, meetings, and red packets.
2023–2024 — CQRS core and infrastructure implementation
7 changes.
This period focused on building the foundational components of the CQRS framework, including command service registration, aggregate caching, and asynchronous processing. It also introduced key infrastructure modules for event sourcing with MySQL sharding, Kafka-based event dispatch, and aggregate snapshotting to support high-concurrency scenarios.
Features
Added aggregate snapshot service for periodic state persistence
The CQRS core now includes a new snapshotting capability to periodically save the state of aggregate roots. This feature introduces an \IAggregateSnapshootService\ interface and a \DefaultAggregateSnapshootService\ implementation that buffers aggregate changes in memory and persists them asynchronously via a scheduled task and a thread pool, helping to reduce the overhead of loading full aggregate histories.
cqrs-core/src/main/java/com/damon/cqrs/snapshot · high confidence
Initial CQRS event sourcing schema
Adds the SQL schema for the CQRS event store, introducing the \event\_offset\ table to track data source and table offsets, and the \event\_stream\_0\ table to persist domain events with unique constraints on aggregate ID/command ID and aggregate ID/version to ensure data integrity.
sql · high confidence
Introduction of CQRS Application Context for Command Service Registration
A new CqrsApplicationContext class has been added to the core library, providing a static registry to map aggregate types to their corresponding ICommandService implementations. This allows the framework to look up and retrieve the appropriate command handler for a given aggregate root type at runtime, serving as the foundational wiring mechanism for the CQRS command side.
cqrs-core/src/main/java/com/damon/cqrs · high confidence
MySQL event store implementation with sharding and async persistence
The cqrs-event-mysql module now provides a concrete MySQL-based event store that supports data sharding across multiple data sources and tables. It introduces a default sharding strategy based on aggregate ID hashing, routes event writes asynchronously via a configurable thread pool, and handles concurrency conflicts (such as duplicate command IDs or version mismatches) by returning specific result types instead of throwing exceptions. Additionally, it includes a MySQL-backed offset tracker to monitor which events have been sent, enabling reliable event replay or processing.
cqrs-event-mysql · high confidence
New CQRS sample applications for goods, meeting reservations, and red packets
The \cqrs-sample-generic-test\ module now includes three new example applications demonstrating the CQRS framework's capabilities. The Goods sample implements a stock deduction workflow (try, commit, cancel) and provides both standard and JDK 19 virtual thread execution modes for performance testing. The Meeting sample demonstrates a reservation system using \BitSet\ for time-slot management, supporting reserve and cancel operations. The Red Packet sample provides a configuration and bootstrap for a distributed red packet grabbing scenario. All samples share a common \TestConfig\ for initializing the CQRS infrastructure (event store, cache, and recovery services).
cqrs-sample/cqrs-sample-generic-test/src/main · high confidence
New Kafka-based event dispatch and send services for CQRS
The cqrs-message-kafka module now includes a complete implementation for sending and consuming domain events via Apache Kafka. This adds a KafkaSendService for publishing events to topics and a KafkaEventDispatch mechanism with orderly listeners for consuming them, including configuration classes for producer and consumer settings (such as offset management and timeout tuning) and a manual retry strategy for failed message processing.
cqrs-message-kafka · high confidence
New SPI extension mechanism for pluggable implementations
The cqrs-spi module now includes a custom Service Provider Interface (SPI) system, introducing the \ExtensionFactory\, \ExtensionLoader\, \SPI\, and \Join\ components. This allows the application to dynamically load and inject implementations of interfaces (marked with \@SPI\) from configuration files located in \META-INF/cqrs/\, enabling users to swap or extend core behaviors without modifying source code. The \SpiExtensionFactory\ provides a concrete implementation to resolve these extensions, and comprehensive tests verify loading, default selection, and error handling for various scenarios.
cqrs-spi · high confidence
New aggregate recovery service with event sourcing and performance logging
Added AggregateRecoveryService to handle the recovery of aggregate roots by loading events from the event store and replaying them to reconstruct state. The service includes detailed logging for event loading and replay durations to help monitor performance, and implements a retry mechanism with locking to ensure reliable recovery even in the presence of transient failures.
cqrs-core/src/main/java/com/damon/cqrs/recovery · high confidence
New utility classes for ID generation and conflict retry
Added AggregateConflictRetryUtils to handle aggregate version conflicts during cluster scaling by retrying operations on AggregateEventConflictException or AggregateCommandConflictException, and added IdWorker to provide efficient 64-bit self-incrementing IDs based on a Snowflake-like algorithm with a system clock optimization.
cqrs-api/src/main/java/com/damon/cqrs/utils · high confidence
Removals
Removal of initial CQRS framework implementation
The initial version of the CQRS framework has been removed from the codebase. This change deletes the core domain classes (Aggregate, Command, DomainService), infrastructure services (EventCommittingService, EventSendingService, AggregateLock, AggregateCache), and sample implementations (GoodsStockService, MysqlEventStore) that previously provided the foundational event sourcing and command handling capabilities.
src/main · high confidence
Behavioural changes
Domain model refactoring and API expansion
The domain layer has been restructured: the \Aggregate\ class is renamed to \AggregateRoot\ and moved to the \com.damon.cqrs.domain\ package, introducing manual snapshot support via \lastSnapTimestamp\ and simplifying uncommitted event handling. New base types \Command\, \Entity\, and \ValueObject\ are added to support sharding parameters and standard entity/value object patterns. The \Event\ class is refactored to implement \Serializable\ directly (replacing Lombok's \@ToString\), with setter methods reorganized to return the instance for chaining, and JSON serialization requirements clarified in comments.
cqrs-api/src/main/java/com/damon/cqrs/domain · high confidence
Exception classes enriched with aggregate context and migrated to new package
The exception classes in the CQRS API have been moved from the \com.nd.cqrs.exception\ package to \com.damon.cqrs.exception\. Additionally, \AggregateCommandConflictException\ and \AggregateEventConflictException\ now expose specific context fields (\aggregateId\, \aggregateType\, and \commandId\ for the former) via new constructors and getters/setters, allowing callers to programmatically inspect the details of the conflict rather than relying solely on the exception message.
cqrs-api/src/main/java/com/damon/cqrs/exception · high confidence
Introduce Caffeine-based aggregate caching and async command processing
The CQRS core now supports local caching of aggregate roots using Caffeine, defined by the new IAggregateCache interface and DefaultAggregateCaffeineCache implementation, to reduce event-sourcing latency. Concurrently, the CommandService has been refactored to process commands asynchronously via CompletableFuture, utilizing ReentrantLocks for aggregate slot locking to handle concurrent updates and timeouts, replacing previous synchronous or Disruptor-based approaches.
cqrs-core/src/main/java/com/damon/cqrs/command · high confidence
Refactored event commit and sending infrastructure with sharding support
The event handling core has been restructured to support scalable event storage and delivery. The \EventCommittingService\ now uses a multi-mailbox architecture to batch and store events, introducing detailed result tracking via \AggregateEventAppendResult\ (distinguishing successes, duplicate commands, duplicate events, and exceptions) and triggering asynchronous aggregate recovery on conflicts. Event persistence now supports custom sharding parameters (\shardingParams\) passed through \DomainEventStream\ and \EventCommittingContext\, routed via the new \IEventShardingRouting\ interface. Additionally, a new \DefaultEventSendingShceduler\ handles the asynchronous dispatch of stored events to message brokers, and the \AggregateSlotLock\ provides configurable distributed locking for aggregate operations.
cqrs-core/src/main/java/com/damon/cqrs/event · high confidence
Refactored utility classes and migrated package namespace
The utility classes in the CQRS core module have been moved from the \com.nd.cqrs.utils\ package to \com.damon.cqrs.utils\. This update includes several behavioral adjustments: \ReflectUtils.newInstance\ now requires an \aggregateId\ to invoke a specific constructor instead of using the default no-arg constructor, \ThreadUtils.sleep\ throws a \RuntimeException\ on interruption instead of printing the stack trace, and a new \NamedThreadFactory\ ensures created threads are non-daemon with normal priority. Additionally, a new \DateUtils\ helper for calculating second differences was added.
cqrs-core/src/main/java/com/damon/cqrs/utils · high confidence
RocketMQ integration refactored with new orderly listener and synchronous sending
The cqrs-message-rocketmq module now includes a new RocketMQOrderlyEventListener for handling ordered message consumption, addressing previous limitations in message ordering guarantees. The RocketMQSendService has been refactored to use synchronous message sending instead of asynchronous callbacks, simplifying error handling and improving reliability for event publishing. Additionally, the DefaultMQProducer class has been moved to the new package structure with minor code optimizations.
cqrs-message-rocketmq · high confidence
Test coverage
Added performance test for red packet operations using virtual threads
Added a new test class \TestRun\ in the \cqrs-sample-generic-test\ module that exercises the \RedPacketCommandService\ under high concurrency. The test creates 2,000 red packets and then simulates 800,000 concurrent grab attempts using Java virtual threads (\Executors.newVirtualThreadPerTaskExecutor\) to measure execution time and validate system stability under load.
cqrs-sample/cqrs-sample-generic-test/src/test · high confidence
Dependencies
Maven dependency and build configuration overhaul
The project's build system has been restructured from a single-module layout to a multi-module architecture (cqrs-api, cqrs-core, cqrs-event-mysql, cqrs-message-kafka, cqrs-message-rocketmq, cqrs-spi, and samples). The root pom.xml now manages versions centrally, upgrading the Java target to 21, bumping Lombok to 1.18.30, RocketMQ client to 4.9.4, and introducing Caffeine (2.9.3), Hutool (5.8.2), and Kafka clients (2.6.0). New modules define specific dependencies, such as HikariCP and MySQL connector for the event store, and Disruptor (3.4.4) for the core.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 50 → 53 (+2.7)
- Rubric changed (rubric-2026.08.17 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 95 → 94 (-1.1)
- Architecture 100 → 93 (-6.2)
- Maturity 43 → 44 (+0.5)
- Readiness 26 → 33 (+7.7)
- Security 100 → 100 (+0.0)
- Domain Modelling 100 → 94 (-6.2)
Resolved (21)
- Change coupling: DefaultEventSendingShceduler.java ↔ EventCommittingService.java (cqrs-core/src/main/java/com/damon/cqrs/event/DefaultEventSendingShceduler.java)
- Coverage not included — suite not readable by the collector
- Dependency hygiene not measured — no supported dependency manifest was read
- Duplicated block (11 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/aggregate/TrainStock.java)
- Duplicated block (13 lines × 5) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/TrainStockMultiSceneTestBootstrap.java)
- Duplicated block (15 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/red_packet/RedPacketServiceBootstrap.java)
- Duplicated block (6 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/goods/GoodsApplication.java)
- Duplicated block (6–13 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/red_packet/RedPacketConfig.java)
- Duplicated block (7 lines × 2) (cqrs-core/src/main/java/com/damon/cqrs/event/EventCommittingService.java)
- Duplicated block (7 lines × 2) (cqrs-message-kafka/src/main/java/com/damon/cqrs/kafka/KafkaMessageHandler.java)
- Duplicated block (7 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/aggregate/TrainStock.java)
- Duplicated block (7 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/aggregate/TrainStock.java)
- Duplicated block (8 lines × 2) (cqrs-event-mysql/src/main/java/com/damon/cqrs/event_store/MysqlEventStore.java)
- Duplicated block (8 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/red_packet/RedPacketConfig.java)
- Duplicated block (8–28 lines × 2) (cqrs-message-kafka/src/main/java/com/damon/cqrs/kafka/config/KafkaConsumerConfig.java)
- No exposed public API
- Test reliability not included
- TrainStock.randomSeatBuyTikcet (cognitive 18) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/aggregate/TrainStock.java)
- TrainStock.selectSeatBuyTicket (cognitive 27) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/aggregate/TrainStock.java)
- TrainStockMultiSceneTestBootstrap.main (cognitive 24) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/TrainStockMultiSceneTestBootstrap.java)
- …and 1 more
New (55)
- Change coupling: EventCommittingService.java ↔ DefaultAggregateSnapshootService.java (cqrs-core/src/main/java/com/damon/cqrs/event/EventCommittingService.java)
- Dependency hygiene PARTLY measured — Maven/Gradle declarations read, no dependency graph resolved
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- Duplicated block (10 lines × 6) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/TrainStockMultiSceneTestBootstrap.java)
- Duplicated block (12 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/red_packet/query/event_handler/RedPacketEventListener.java)
- Duplicated block (16 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/red_packet/RedPacketServiceBootstrap.java)
- Duplicated block (18 lines × 5) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/TrainStockMultiSceneTestBootstrap.java)
- Duplicated block (26 lines × 5) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/aggregate/value_object/UserSeatInfo.java)
- Duplicated block (28 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/red_packet/RedPacketServiceBootstrap.java)
- Duplicated block (35 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/command/TicketProtectCancelCommand.java)
- Duplicated block (5 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/goods/GoodsApplication.java)
- Duplicated block (51 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/aggregate/value_object/UserSeatInfo.java)
- Duplicated block (5–6 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/TestConfig.java)
- Duplicated block (6 lines × 6) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/train/TrainStockMultiSceneTestBootstrap.java)
- Duplicated block (7 lines × 2) (cqrs-message-kafka/src/main/java/com/damon/cqrs/kafka/KafkaMessageHandler.java)
- Duplicated block (7 lines × 3) (cqrs-core/src/main/java/com/damon/cqrs/event/EventCommittingService.java)
- Duplicated block (7–10 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/TestConfig.java)
- Duplicated block (8 lines × 2) (cqrs-event-mysql/src/main/java/com/damon/cqrs/event_store/MysqlEventStore.java)
- Duplicated block (9 lines × 2) (cqrs-sample/cqrs-sample-generic-test/src/main/java/com/damon/cqrs/sample/TestConfig.java)
- …and 35 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
654894017/cqrs was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit e5a26a104f1313fec6f19e402b98eafb7ceedb48 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-28e75b8e3254.