All Projects → BranislavLazic → akka-cqrs-activator

BranislavLazic / akka-cqrs-activator

Licence: Apache-2.0 license
Issue tracker PoC application written in Scala (Akka) and JavaScript (React) that demonstrates event sourcing and CQRS

Programming Languages

scala
5932 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to akka-cqrs-activator

Orleankka
Functional API for Microsoft Orleans http://orleanscontrib.github.io/Orleankka/
Stars: ✭ 429 (+1200%)
Mutual labels:  actors, cqrs, fsm
endless
Scala library to describe sharded and event sourced entities using tagless-final algebras
Stars: ✭ 70 (+112.12%)
Mutual labels:  actors, akka, cqrs
Akkatecture
a cqrs and event sourcing framework for dotnet core using akka.net
Stars: ✭ 414 (+1154.55%)
Mutual labels:  actors, akka, cqrs
Protoactor Go
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
Stars: ✭ 3,934 (+11821.21%)
Mutual labels:  actors, akka
akka-http-quickstart-java.g8
akka.io
Stars: ✭ 17 (-48.48%)
Mutual labels:  akka, akka-http
Robots
Actor system for Rust
Stars: ✭ 294 (+790.91%)
Mutual labels:  actors, akka
Akkadotnet Code Samples
Akka.NET professional reference code samples
Stars: ✭ 451 (+1266.67%)
Mutual labels:  actors, akka
Akka Essentials
Java/Scala Examples from the book - Akka Essentials
Stars: ✭ 700 (+2021.21%)
Mutual labels:  actors, akka
Riker
Easily build efficient, highly concurrent and resilient applications. An Actor Framework for Rust.
Stars: ✭ 745 (+2157.58%)
Mutual labels:  actors, cqrs
Akka Monitoring
Monitoring system instrumentation for Akka.NET actor systems
Stars: ✭ 105 (+218.18%)
Mutual labels:  actors, akka
Protoactor Dotnet
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
Stars: ✭ 1,070 (+3142.42%)
Mutual labels:  actors, akka
Actors
Evaluation of API and performance of different actor libraries
Stars: ✭ 125 (+278.79%)
Mutual labels:  actors, akka
Core
CQRS-DDD-Actor framework for Node.js
Stars: ✭ 273 (+727.27%)
Mutual labels:  actors, cqrs
akka-http-streaming-response-examples
A list of examples that involve streaming with Akka Streams and used together with Akka HTTP
Stars: ✭ 73 (+121.21%)
Mutual labels:  actors, akka-http
protoactor-go
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
Stars: ✭ 4,138 (+12439.39%)
Mutual labels:  actors, akka
nact
nact ⇒ node.js + actors ⇒ your services have never been so µ
Stars: ✭ 1,003 (+2939.39%)
Mutual labels:  actors, akka
Akka Guide
🌴 A chinese guide of Akka, based on Java.
Stars: ✭ 217 (+557.58%)
Mutual labels:  actors, akka
akka-contextual-actor
A really small library (just a few classes) which lets you trace your actors messages transparently propagating a common context together with your messages and adding the specified values to the MDC of the underlying logging framework.
Stars: ✭ 17 (-48.48%)
Mutual labels:  actors, akka
MuezzinAPI
A web server application for Islamic prayer times
Stars: ✭ 33 (+0%)
Mutual labels:  actors, akka
Nact
nact ⇒ node.js + actors ⇒ your services have never been so µ
Stars: ✭ 848 (+2469.7%)
Mutual labels:  actors, akka

Akka CQRS activator

Issue tracking demo application which shows implementation of event sourcing and CQRS with Akka

Technical requirements:

  • Scala 2.12
  • docker-compose version 1.8
  • SBT
  • Node

Up and run:

  • In root directory execute command: docker-compose up -d to start Cassandra
  • Then execute command: sbt to enter sbt console and execute ;yarn;reStart command (yarn command installs node_modules and builds the frontend) to start server (to stop server, type reStop and hit enter within the same sbt session). You should be able to access application at: http://localhost:8000 .
  • Use sbt a to build executable JAR (/target/scala-2.12)

alt text

General concept:

Data store

Cassandra is being used as an event store and also as a "read side" data store. Normally, event store and "read side" data store should be separated.

Write side

On the write side, Akka Persistent FSM actor is being used to store current state and to define behavior. In our case - IssueRepository. IssueRepositoryManager is being used to manage creation of IssueRepository actors. Each time when new issue is being created, new IssueRepository actor is being created with unique id. Therefore, one actor per issue. The unique id is composed of time UUID and date (which is date of creation). If the actor is not existing in the context of IssueRepositoryManager, then the actor is being created as a new one, or recovered by provided id. In case of recovery, events will be replayed and actor will be recovered to its latest state.

With FSM mechanism, we're preventing creation of two same issues or undesired behaviors. Such as: Deleting an issue before it's created, closing an issue which is deleted, updating an issue with is deleted etc.

Eventually, actor will pass through four states. Idle, IssueCreatedState, IssueClosedState and IssueDeletedState.

Each IssueRepository actor is being persisted with common tag - "issue-tag". Since id is not common, we will use Akka Persistence Query to subscribe to events by a common tag.

Read side

On the read side, IssueService is being used to poll Cassandra event store and to subscribe on a stream of events. Events are being sent to IssueService itself, their data are being processed, published to the DistributedPubSub mediator and then used in execution of CQL statements against Cassandra read side data store. Other tasks of IssueVew actor are to query Cassandra database and to create read side keyspace and table.

Http API

In this case, we're using Akka HTTP to expose our ES & CQRS implementation to the "outer world". HttpApi actor will start Akka HTTP server with few routes for:

  • Creating, updating, closing and deleting issues
  • Querying database (obtaining all issues for specific date and issue by date and id)
  • Event stream

In a concept of CQRS, write and read side are asynchronous. Therefore, we'll always face eventual consistency issue. Which simply means: When written, data will not be immediately available for reading. In this example, we solved this issue by publishing event to the DistributedPubSub mediator when it reaches its read side, then the issue is published via event stream as a server sent event. Therefore, a frontend application can subscribe on this event stream and live update its UI.

Frontend

Client side rendering with React.

Influenced by: Reactive Flows

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].