Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cloudogu/command-bus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

command-bus

Build Status Quality Gates Coverage Technical Debt JitPack

CDI enabled Java Command-Bus

Concepts

  • Command - Marker Interface
  • CommandHandler - One Implementation per Command. Provides handle(CommandImplementation) Method.
  • CommandBus - Finds and calls the CommandHandler for each Command.
  • CommandBus can be decorated, in order to implement cross-cutting concerns, such as logging, transaction handling, validation, autorization, metrics etc.

Usage (CDI)

You can use JitPack to configure command-bus as a dependency in your project.
For example when using maven, define the JitPack repository:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

And the command-bus dependency:

<dependency>
    <groupId>com.github.triologygmbh</groupId>
    <artifactId>command-bus</artifactId>
   <version>0.1.0</version>
</dependency>

For further details and options refer to the JitPack website.

Command Bus Decorators

First example is the logging decorator (LoggingCommandBus) that logs entering and leaving (including time of execution) of CommandHandlers.

Prometheus metric decorators

The Triology Command Bus provides two Prometheus metrics decorators. More information on Prometheus can be found on the project's website. In order to use them, make sure to provide the io.prometheus:simpleclient dependency on the classpath.

PrometheusMetricsCountingCommandBus

The PrometheusMetricsCountingCommandBus counts every executed command, using a Prometheus Counter. The counter to be used must be provided as a constructor parameter. For each type of command (i.e. it's class name) a label is created automatically.

PrometheusMetricsTimingCommandBus

The PrometheusMetricsTimingCommandBus captures the time a command's execution takes and provides the metric as a Prometheus Histogram. Similarly to the PrometheusMetricsCountingCommandBus, the Histogram needs to be provided as a constructor parameter.

Return values

About

Java implementation of the Command-Bus pattern for Spring and CDI

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages