Complex event flows in distributed systems · Complex event flows in distributed systems...

96
Complex event flows in distributed systems @berndruecker

Transcript of Complex event flows in distributed systems · Complex event flows in distributed systems...

Page 1: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Complex event flows indistributed systems

@berndruecker

Page 2: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

3 common hypotheses I check today:

# Events decrease coupling# Orchestration needs to be avoided# Workflow engines are painful

@berndruecker

Page 3: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Warning:Contains Opinion

Page 4: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Berlin, Germany

[email protected]@berndruecker

Bernd RueckerCo-founder and Chief Technologist ofCamunda

Page 5: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment
Page 6: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Simplified example:dash button

Photo by 0xF2, available under Creative Commons BY-ND 2.0 license. https://www.flickr.com/photos/0xf2/29873149904/

@berndruecker

Page 7: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Three steps…@berndruecker

Page 8: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Who is involved? Some bounded contexts…

Checkout

Payment

Inventory

Shipment

@berndruecker

Page 9: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

(Micro-)services

Checkout

Payment

Inventory

Shipment

@berndruecker

Page 10: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Autonomous (micro-)services

Checkout

Payment

Inventory

Shipment

Dedicated Application Processes

Dedicated infrastructure

Dedicated Development Teams

@berndruecker

Page 11: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Events decrease coupling

@berndruecker

Page 12: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Example

Checkout

Payment

Inventory

Shipment

The button blinks if we canship within 24 hours

@berndruecker

Page 13: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Request/response: temporal coupling

Checkout

Payment

Inventory

Shipment

RequestResponse

The button blinks if we canship within 24 hours

@berndruecker

Page 14: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Temporal decoupling with events and read models

Checkout

Payment

Inventory

Shipment

GoodStored

Read Model

GoodFetched

The button blinks if we canship within 24 hours

*Events are facts about what happened (in the past)

@berndruecker

Page 15: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

OrderPlaced

PaymentReceived

GoodsFetched

Notification

Checkout

Payment

Inventory

Shipment

Event-driven architecture@berndruecker

Page 16: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Events can decrease coupling*

*e.g. decentral data-management, read models, extract cross-cutting aspects

@berndruecker

Page 17: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Peer-to-peer event chains

Checkout

Payment

Inventory

Shipment

Order placed

Payment received

Goodsshipped

Goodsfetched

@berndruecker

Page 18: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Peer-to-peer event chains

Checkout

Payment

Inventory

Shipment

Order placed

Payment received

Goodsshipped

Goodsfetched

@berndruecker

Page 19: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

The danger is that it's very easy to make nicely decoupled systems with event notification, without realizing that you're losing sight of that larger-scale flow, and thus set yourself up for trouble in future years.

https://martinfowler.com/articles/201701-event-driven.html

@berndruecker

Page 20: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

The danger is that it's very easy to make nicely decoupled systems with event notification, without realizing that you're losing sight of that larger-scale flow, and thus set yourself up for trouble in future years.

https://martinfowler.com/articles/201701-event-driven.html

@berndruecker

Page 21: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

The danger is that it's very easy to make nicely decoupled systems with event notification, without realizing that you're losing sight of that larger-scale flow, and thus set yourself up for trouble in future years.

https://martinfowler.com/articles/201701-event-driven.html

@berndruecker

Page 22: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Monitoring Workflows Across Microservices

https://www.infoq.com/articles/monitor-workflow-collaborating-microservices

@berndruecker

Page 23: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Typical approachesDistributed Tracing

Data Lake / Event Monitoring

Process Mining

Process Tracking

@berndruecker

Page 24: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Stefan Tilkov: Microservice Patterns & Antipatterns - MicroXchg 2018

@berndruecker

Page 25: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Peer-to-peer event chains

Checkout

Payment

Inventory

Shipment

Order placed

Payment received

Goodsshipped

Goodsfetched

Fetch the goodsbefore thepayment

@berndruecker

Page 26: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Peer-to-peer event chains

Checkout

Payment

Inventory

Shipment

Fetch the goodsbefore thepayment

Goodsfetched

Order placed

Payment received

Goodsshipped

@berndruecker

Page 27: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Photo by born1945, available under Creative Commons BY 2.0 license.

@berndruecker

Page 29: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

„Challenges?“

Source: Microservices orchestration survey, July 2018, 354 responses

https://camunda.com/microservices-orchestration-survey-results-2018/

@berndruecker

Page 30: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Order

Extract the end-to-end responsibility

Checkout

Payment

Inventory

Shipment

*Commands have an intent about what needs to happen in the future

Paymentreceived

Order placed

Retrievepayment

@berndruecker

Page 31: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Order

It is about where to decide about the coupling!

Checkout

Payment

Inventory

Shipment

Order placed

Retrievepayment

Order decides. to listen to the event. to issue the command

@berndruecker

Page 32: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Order

It is about where to decide about the coupling!

Checkout

Payment

Inventory

Shipment

Order placed

Retrievepayment

It can still be messaging!

@berndruecker

Page 33: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Commands help to avoid (complex)peer-to-peer event chains

@berndruecker

Page 34: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Orchestration needs to be avoided

@berndruecker

Page 35: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Smart ESB-like middleware

Checkout

Payment

Inventory

Shipment

Order

Order placed

Payment received

Goodfetched

Goodshipped

@berndruecker

Page 36: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Dumb pipes

Checkout

Payment

Inventory

Shipment

Order

Smart endpoints and dumb pipes

Martin Fowler

@berndruecker

Page 37: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Danger of god services?

Checkout

Order

A fewsmart god services tellanemic CRUD services what to do

Sam Newmann

Payment

Inventory

Shipment

@berndruecker

Page 38: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Danger of god services?

Checkout

Payment

Inventory

Shipment

Order

A fewsmart god services tellanemic CRUD services what to do

Sam Newmann

@berndruecker

Page 39: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

A god service is only createdby bad API design!

@berndruecker

Page 40: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Example

Order Payment

RetrievePayment

@berndruecker

Page 41: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Example

Order PaymentCreditCard

RetrievePayment

@berndruecker

Page 42: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Example

Order PaymentCreditCard

RetrievePayment

Rejected

@berndruecker

Page 43: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Example

Order Payment

If the creditcard was

rejected, thecustomer canprovide new

details

CreditCard

RetrievePayment

RejectedRejected

@berndruecker

Page 44: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Example

Order Payment

Client of dumb endpoints easily become a god services.

If the creditcard was

rejected, thecustomer canprovide new

details

CreditCard

RetrievePayment

RejectedRejected

@berndruecker

Page 45: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Paymentfailed

Who is responsible to deal with problems?

Order Payment

If the credit card was

rejected, the customer can provide new

details

CreditCard

RetrievePayment

RejectedPaymentreceived

@berndruecker

Page 46: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Paymentfailed

Long running services

Order PaymentCreditCard

RetrievePayment

RejectedPaymentreceived

Smart endpoints are potentially long-running

@berndruecker

Page 47: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Persist thing(Entity, Actor, …)

State machine orworkflow engine

Typicalconcerns

DIY = effort, accidentalcomplexity

Scheduling, Versioning, operating, visibility, scalability, …

Handling State

@berndruecker

Page 48: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Workflow engines are painful

Complex, proprietary, heavyweight, central, developer adverse, …

@berndruecker

Page 49: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Avoid the wrong tools!

Death by properties panel

Low-code is great!(You can get rid

of your developers!)

Complex, proprietary, heavyweight, central, developer adverse, …

@berndruecker

Page 50: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Workflow engines, state machines

It is

relevantin modern

architectures

@berndruecker

Page 51: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

CADENCE

Silicon valleyhas recognized

Workflow engines, state machines

@berndruecker

Page 52: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

CADENCEWorkflow engines, state machines

@berndruecker

Page 53: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

public static void main(String[] args) { ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration().buildProcessEngine();

engine.getRepositoryService().createDeployment() //.addModelInstance("flow.bpmn", Bpmn.createExecutableProcess("flow") //.startEvent().serviceTask("Step1").camundaClass(SysoutDelegate.class).serviceTask("Step2").camundaClass(SysoutDelegate.class).endEvent()

.done()).deploy();

engine.getRuntimeService().startProcessInstanceByKey("flow", Variables.putValue("city", "New York"));

}public class SysoutDelegate implements JavaDelegate {public void execute(DelegateExecution execution) throws Exception {System.out.println("Hello " + execution.getVariable("city"));

}}

What do I mean by„leightweight?“

@berndruecker

Page 54: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

public static void main(String[] args) { ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration().buildProcessEngine();

engine.getRepositoryService().createDeployment() //.addModelInstance("flow.bpmn", Bpmn.createExecutableProcess("flow") //.startEvent().serviceTask("Step1").camundaClass(SysoutDelegate.class).serviceTask("Step2").camundaClass(SysoutDelegate.class).endEvent()

.done()).deploy();

engine.getRuntimeService().startProcessInstanceByKey("flow", Variables.putValue("city", "New York"));

}public class SysoutDelegate implements JavaDelegate {public void execute(DelegateExecution execution) throws Exception {System.out.println("Hello " + execution.getVariable("city"));

}}

Build enginein one line ofcode(using in-memory H2)

@berndruecker

Page 55: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

public static void main(String[] args) { ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration().buildProcessEngine();

engine.getRepositoryService().createDeployment() //.addModelInstance("flow.bpmn", Bpmn.createExecutableProcess("flow") .startEvent().serviceTask("Step1").camundaClass(SysoutDelegate.class).serviceTask("Step2").camundaClass(SysoutDelegate.class).endEvent()

.done()).deploy();

engine.getRuntimeService().startProcessInstanceByKey("flow", Variables.putValue("city", "New York"));

}public class SysoutDelegate implements JavaDelegate {public void execute(DelegateExecution execution) throws Exception {System.out.println("Hello " + execution.getVariable("city"));

}}

Define flowe.g. in Java DSL

@berndruecker

Page 56: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

public static void main(String[] args) { ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration().buildProcessEngine();

engine.getRepositoryService().createDeployment() //.addModelInstance("flow.bpmn", Bpmn.createExecutableProcess("flow") .startEvent().serviceTask("Step1").camundaClass(SysoutDelegate.class).serviceTask("Step2").camundaClass(SysoutDelegate.class).endEvent()

.done()).deploy();

engine.getRuntimeService().startProcessInstanceByKey("flow", Variables.putValue("city", "New York"));

}public class SysoutDelegate implements JavaDelegate {public void execute(DelegateExecution execution) throws Exception {System.out.println("Hello " + execution.getVariable("city"));

}}

Define flowe.g. in Java DSL

@berndruecker

Page 57: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

BPMNBusiness Process

Model and Notation

ISO Standard

@berndruecker

Page 58: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

public static void main(String[] args) { ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration().buildProcessEngine();

engine.getRepositoryService().createDeployment() //.addModelInstance("flow.bpmn", Bpmn.createExecutableProcess("flow") .startEvent().serviceTask("Step1").camundaClass(SysoutDelegate.class).serviceTask("Step2").camundaClass(SysoutDelegate.class).endEvent()

.done()).deploy();

engine.getRuntimeService().startProcessInstanceByKey("flow", Variables.putValue("city", "New York"));

}public class SysoutDelegate implements JavaDelegate {public void execute(DelegateExecution execution) throws Exception {System.out.println("Hello " + execution.getVariable("city"));

}}

We can attachcode…

@berndruecker

Page 59: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

public static void main(String[] args) { ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration().buildProcessEngine();

engine.getRepositoryService().createDeployment() //.addModelInstance("flow.bpmn", Bpmn.createExecutableProcess("flow") .startEvent().serviceTask("Step1").camundaClass(SysoutDelegate.class).serviceTask("Step2").camundaClass(SysoutDelegate.class).endEvent()

.done()).deploy();

engine.getRuntimeService().startProcessInstanceByKey("flow", Variables.putValue("city", "New York"));

}public class SysoutDelegate implements JavaDelegate {public void execute(DelegateExecution execution) throws Exception {System.out.println("Hello " + execution.getVariable("city"));

}}

…that iscalled whenworkflowinstances pass through

@berndruecker

Page 60: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

public static void main(String[] args) { ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration().buildProcessEngine();

engine.getRepositoryService().createDeployment() //.addModelInstance("flow.bpmn", Bpmn.createExecutableProcess("flow") .startEvent().serviceTask("Step1").camundaClass(SysoutDelegate.class).serviceTask("Step2").camundaClass(SysoutDelegate.class).endEvent()

.done()).deploy();

engine.getRuntimeService().startProcessInstanceByKey("flow", Variables.putValue("city", "New York"));

}public class SysoutDelegate implements JavaDelegate {public void execute(DelegateExecution execution) throws Exception {System.out.println("Hello " + execution.getVariable("city"));

}}

Start instances

@berndruecker

Page 61: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Payment

Now you have a state machine!@berndruecker

Page 62: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Payment

Easy to handle time@berndruecker

Page 63: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Distributedsystems

@berndruecker

Page 64: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Example with synchronous communication

RESTOrder Payment

CreditCard

@berndruecker

Page 65: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Example with synchronous communication

RESTOrder Payment

CreditCard

@berndruecker

Page 66: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Example with synchronous communication

REST

Order PaymentCreditCard

@berndruecker

Page 67: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Example with synchronous communication

RESTOrder Payment

CreditCard

StatefulRetry

@berndruecker

Page 68: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Works also for asynchronous communication

Order PaymentCreditCard

Monitor Timeouts

@berndruecker

Page 69: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Distributedsystems

@berndruecker

Page 70: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

It is impossible todifferentiate certain

failure scenarios:

Independant ofcommunication style!

Service Provider

Client

@berndruecker

Page 71: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Distributed systems introduce complexity you have to tackle!

CreditCard

PaymentREST

@berndruecker

Page 72: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Distributed systems introduce complexity you have to tackle!

CreditCard

PaymentREST

The service can belong running.You get a better API and less gods

@berndruecker

Page 73: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Workflows live inside service boundaries@berndruecker

Page 74: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

No BPM(N) monoliths

https://blog.bernd-ruecker.com/avoiding-the-bpm-monolith-when-using-bounded-contexts-d86be6308d8

@berndruecker

Page 75: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Pat Helland

Distributed Systems Guru Worked at Amazon, Microsoft & Salesforce

@berndruecker

Page 76: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Pat Helland

Grown-Ups Don’t Use Distributed Transactions

Distributed Systems Guru Worked at Amazon, Microsoft & Salesforce

@berndruecker

Page 77: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Distributed transactions using compensation *

Compensation

@berndruecker

Page 78: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Homework:Try to do this purely event-driven!

Send to: [email protected]

@berndruecker

Page 79: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Biz Dev

Leveragestate machine & workflow engine

Living documentation

Visibility in testing

improvecommunication

improvecommunication

Ops

@berndruecker

Page 80: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Visual HTML reports for test cases@berndruecker

Page 81: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Living documentation for long-running behaviour@berndruecker

Page 82: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

ProperOperations

Visibility + Context

@berndruecker

Page 83: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Biz Dev

Leveragestate machine & workflow engine

Living documentation

Visibility in testing

Operate with visibilityand context

Understand and discussbusiness processes

Evaluate optimizationsin-sync with

implementation

improvecommunication

improvecommunication

Ops

@berndruecker

Page 84: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Monitoring Workflows Across Microservices

https://www.infoq.com/articles/monitor-workflow-collaborating-microservices

@berndruecker

Page 85: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Tracking

Checkout Inventory

Payment Shipment

Event Bus

Workflow Engine

https://www.confluent.io/kafka-summit-sf18/the_big_picture @berndruecker

Page 86: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Journey towards more orchestration@berndruecker

Page 87: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Vodafone, Liongate & WDWPresented at CamundaCOn Berlin 2018

Page 88: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Before mapping processes explicitly with BPMN, the truth was buried in the code and nobody knew what was going on.

Jimmy Floyd, 24 Hour Fitnesse

@berndruecker

Page 89: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

…It addresses one of the core issues in a distributed microservices architecture—where is the source of truth for the coordinated interaction of the entire system?…the system we are replacing uses a complex peer-to-peer choreography that requires reasoning across multiple codebases to understand.

https://medium.com/@sitapati/node-js-client-for-zeebe-microservices-orchestration-engine-72287e4c7d94

Josh WulfCredit Sense

@berndruecker

Page 90: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Lightweight workflow engines aregreat – don‘t DIY*

*e.g. enabling potentially long-running services, solving harddeveloper problems, can run decentralized

@berndruecker

Page 91: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Sales-Order & Order-Fulfillment

via Camunda

for every order worldwide

(Q2 2017: 22,2 Mio)

@berndruecker

Page 92: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Code, code, code…@berndruecker

Page 93: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Event-driven example

InventoryPaymentOrder ShippingCheckout Monitor

https://github.com/berndruecker/flowing-retail/

Human Tasks

H2 H2

@berndruecker

Page 94: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

# Events decrease coupling: sometimesread-models, but no complex peer-to-peer event chains!

# Orchestration needs to be avoided: sometimesno ESB, smart endpoints/dumb pipes, balance orchestration and choreography

# Workflow engines are painful: some of themlightweight engines are easy to use and can run decentralized,they solve hard developer problems, don‘t DIY

@berndruecker

Page 95: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

Thank you!

@berndruecker

Page 96: Complex event flows in distributed systems · Complex event flows in distributed systems @berndruecker. 3 common hypotheses I check today: ... Peer-to-peer event chains Checkout Payment

[email protected]@berndruecker

https://berndruecker.io

https://medium.com/berndruecker

https://github.com/berndruecker

https://www.infoq.com/articles/events-workflow-automation

Contact:

Slides:

Blog:

Code:

https://www.infoworld.com/article/3254777/application-development/3-common-pitfalls-of-microservices-integrationand-how-to-avoid-them.html

https://thenewstack.io/5-workflow-automation-use-cases-you-might-not-have-considered/