43
Innovative solutions with Axon Framework Allard Buijze [email protected] @allardbz At ANWB, Casumo, Gerimedica, Bridge Big

Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – [email protected] – @allardbz

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Innovative solutions with Axon Framework

Allard Buijze – [email protected] – @allardbz At ANWB, Casumo, Gerimedica, Bridge Big

Page 2: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Four cases

Page 3: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Casumo

Online Casino

Games, Slot machines

High volumes

Auditing requirements

“Keep the spin button FAST!”

Page 4: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

ANWB

Emergency assistance call-center

Task based system

3rd party integrations

Reporting requirements

Somewhat predictable peak-loads

Page 5: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Bridge Big

Online Bridge platform

Participants play for money

Large-scale tournaments

Elastically scalable

“Keep the game flowing smoothly”

Page 6: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Gerimedica

Electronic Medical Record

SaaS solution

Many integrations

High availability

Medical analysis on historic data

“Improve healthcare through technology and sharing knowledge”

Page 7: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

What connects these cases?

?

Page 8: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Complex domain model

Page 9: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Complex environment

Page 10: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Value in history

Page 11: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Performance expectations

Page 12: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Avoid the Big ball of “Mud”

Source: http://www.sabisabi.com/images/DungBeetle-on-dung.JPG

Page 13: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Microservice Architecture

Source: http://martinfowler.com/articles/microservices.html

Page 14: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Microservices vs Monoliths

Almost all the cases where I've heard of a system that was built as a microservice system from scratch, it has ended up in serious trouble.

Almost all the successful microservice stories have started with a monolith that got too big and was broken up

Martin Fowler

Source: http://martinfowler.com/bliki/MonolithFirst.html

Page 15: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

A Monolith is not (always) a Big Ball of Mud

St Breock Downs Monolith - www.cornwalls.co.uk

Page 16: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Desired evolution

1 – Build a monolith 2 – Extract components 3 – Extract more 4 – Scale as needed

Page 17: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Axon Framework

“CQRS Framework” for Java

Open source (Apache 2 License)

Simplify CQRS based applications

Building blocks common in CQRS-based architectures

3.0-M1 released on 10th June, 2016

axonframework.org

Page 18: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Axon Framework – Core Principles

Message oriented

Events Commands

Location transparency

Separate infrastructure from business logic

Customizable

Configure to match your infrastructure, not vice versa

Page 19: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

CQRS

Page 20: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

CQRS Based Architecture

Command model Projections

Page 21: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

CQRS Based Architecture

Command model Projections

T: 1 mln / s Resp: < 10 ms

T: Thr. 20 / s Resp: < 100 ms

T: 10 mln / s Resp. < 100 ms

T: 1 / s Resp. < 10 ms

Page 22: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Synchronizing models

Command model Projections

Events

Page 23: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

CQRS Based Architecture

Page 24: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Separate infrastructure from business logic

A

D

B

E

C

Page 25: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Spring configuration - Simple

EmbeddedEventStore

TrackingEventProcessor

SimpleCommandBus

Page 26: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Separate infrastructure from business logic

A

D

B

E

C

Page 27: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Separate infrastructure from business logic

A

D

B

E

C

Page 28: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Infrastructure components – Distributed Setup

EmbeddedEventStore

TrackingEventProcessor

DistributedCommandBus

Page 29: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Separate infrastructure from business logic

A

D

B

E

C

Page 30: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Separate infrastructure from business logic

A

D

B

E

C

Page 31: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Infrastructure components – Clustered Setup

EmbeddedEventStore

ClusteringEventProcessor

DistributedCommandBus

Page 32: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

CQRS Based Architecture

Page 33: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Axon – Command Bus API

commandBus.dispatch(commandMessage, new VoidCallback() { @Override public void onSuccess() { ... } @Override public void onFailure(Throwable cause) { ... } });

@CommandHandler public void handle(CreateToDoItemCommand command) { // handle command }

Page 34: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Axon – Event Bus API

@EventHandler public void onEvent(ToDoItemCompletedEvent event) { // handle event }

eventBus.publish(asEventMessage(new ToDoItemCompletedEvent(“todo1”)));

Page 35: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

CQRS Based Architecture

class AggregateLifecycle @CommandHandler @EventSourcingHandler

Page 36: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Event Sourcing

Page 37: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Event Sourcing

ID OrderID Product Count 1 1 Deluxe Chair 1

2 1 ... ...

vs

OrderItems

Seq# Event 0 OrderCreatedEvent

1 ItemAddedEvent (2x Deluxe Chair - € 399)

2 ItemRemovedEvent (1x Deluxe Chair - € 399)

3 OrderConfirmed

4 OrderCancelledByUserEvent

5 ReturnShipmentReceived

ID Status 1 Return shipment rcvd

Orders

Page 38: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Event Logs

Page 39: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

CQRS Based Architecture

interface EventStore class EmbeddedEventStore class JpaEventStorageEngine class JdbcEventStorageEngine class MongoEventStorageEngine

class TrackingEventProcessor class SubscribingEventProcessor

Page 40: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Summarizing

Page 41: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Axon Framework – Some cases

Finance

Process automation in a top 50 bank Trading engine for ETF (index trackers) trading On-line payment processing

Gaming & Betting

On-line bridge platform (bridgebig.com) On-line casino (casumo.com) Price calculation at large betting office

Healthcare

Electronic Medical Record for the Geriatric Healthcare Tracking and Tracing of equipment for dental implants

Transportation & Logistics

Optimizing aircraft movement at several large airports

Page 42: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

Getting started...

Download: axonframework.org/download

or: maven central repository

Code: github.com/AxonFramework

Help: [email protected]

or: @axonframework

Page 43: Innovative solutions with Axon Frameworkgotocon.com/dl/goto-amsterdam-2016/slides/Allard... · Innovative solutions with Axon Framework Allard Buijze – abu@trifork.com – @allardbz

More information

www.axonframework.org Allard Buijze <[email protected]> – @allardbz @axonframework