Skip to content

Latest commit

 

History

History
96 lines (67 loc) · 1.9 KB

README.md

File metadata and controls

96 lines (67 loc) · 1.9 KB

Build Status codecov

Reactive CQRS + ES lib

This is simple lib which adds reactive command handling classes to your springboot app

Key features:

  • dispatches command to reactive handlers

Scheduled functionality

  • Event bus
  • Command bus with handler that could return event
  • automatically apply event on bus

Usage

Import lib

With maven

<dependency>
  <groupId>io.github.yasiekz</groupId>
  <artifactId>reactive-cqrs-es-lib</artifactId>
  <version>1.0.0</version>
</dependency>

With gradle

repositories {
    mavenCentral()
}

dependencies {
    implementation 'io.github.yasiekz:reactive-cqrs-es-lib:1.0.0'
}
Register bean in @Configuration class
@Configuration
public class CqrsConfiguration {
    
    @Bean
    public CommandDispatcher createSimpleCommandBus(List<SimpleCommandHandler> handlers) {
        return new SimpleCommandBus(handlers);
    }
}
Create some commands
import io.github.yasiekz.reactive.cqrses.command.Command;

public class DummyCommand extends Command {
    // some data here with getters
}

Important Commands should be immutable!

Create handler for Command
package io.github.yasiekz.reactive.cqrses.command.SimpleCommandHandler;

import reactor.core.publisher.Mono;

public class DummyCommandHandler implements SimpleCommandHandler<DummyCommand> {

    @Override
    public Mono<Void> handle(final DummyCommand command) {
        // do something with command using reactive flow
    }
}

Local run

Requirements

  • Java 11 to build project
  • Spring boot 2.1.x

Run tests

./gradlew check