36
Event-Driven UI using the Reactive Interaction Gateway Kevin Bader, Accenture

Event-Driven UI

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Event-Driven UI

Event-Driven UIusing theReactive Interaction Gateway

Kevin Bader, Accenture

Page 2: Event-Driven UI

2

LIVE UPDATES

Page 3: Event-Driven UI

3

ASYNC PROCESSING

Page 4: Event-Driven UI

Example: Conference Registration

• Allow people to register to the conference• When someone has registered:

• send an email to the organizing team

• send an email to the new participant

• Assign a mentor to the participant• It might take a while to find a good match..

ASYNC PROCESSING

4github.com/mmacai/openslava-2019-rig-example

Page 5: Event-Driven UI

5

CONFERENCE REGISTRATION

submitregistration form

participant registered

mentor assigned

conference service

all the data,all the events

github.com/mmacai/openslava-2019-rig-example

Page 6: Event-Driven UI

6

CONFERENCE REGISTRATION

registrationservice

mentoringservice

communicationsservice

participants,registrations

mentors,mentees

recipients,email templates

github.com/mmacai/openslava-2019-rig-example

Page 7: Event-Driven UI

7

CONFERENCE REGISTRATION

registrationservice

mentoringservice

communicationsservice

submitregistration form

participantregistered

mentorassigned

github.com/mmacai/openslava-2019-rig-example

Page 8: Event-Driven UI

8

CONFERENCE REGISTRATION

submitregistration form

registrationservice

mentoringservice

communicationsservice

participantregistered

mentorassigned

github.com/mmacai/openslava-2019-rig-example

Page 9: Event-Driven UI

• 13 min

© 2019 Accenture

a (web) app is an application

Page 10: Event-Driven UI

10

LET THE FRONTEND (TEAM) PARTICIPATE

Service A Service B

"A" happened "B" happened

Frontend

Service A Service B

"A" happened "B" happened

Frontend

Page 11: Event-Driven UI

11

Microservices emit events.Frontends consume and produce events the same way other microservices do.Frontends not aware how eventsare stored.

LET THE FRONTEND (TEAM) PARTICIPATE

Enable the frontend toparticipate in choreography:• Frontends subscribe to events• Microservice emit events and

don’t target specific frontends• Frontend team gains autonomy

Service A Service B

"A" happened "B" happened

Frontend

Service A Service B

"A" happened "B" happened

Frontend

Page 12: Event-Driven UI

12

Microservices emit events.Frontends consume and produce events the same way other microservices do.Frontends not aware how eventsare stored.

LET THE FRONTEND (TEAM) PARTICIPATE

Frontends communicatesthe user’s actions.

Microservices can react:• start a (long-running) process• analyze a user’s behavior• notify the support staff

Service A

Service B

the user did something

Frontend

Page 13: Event-Driven UI

13

Microservices emit events.Frontends consume and produce events the same way other microservices do.Frontends not aware how eventsare stored.

LET THE FRONTEND (TEAM) PARTICIPATE

• Decouples teams• Topic partitioning should not be part of

the interface

events

Frontend

?

Page 14: Event-Driven UI

• 13 min

© 2019 Accenture

how to implement this?

Page 15: Event-Driven UI

15

REACTIVE INTERACTION GATEWAY (RIG)

Page 16: Event-Driven UI

16

INTEGRATION

Business Logic

Local data

API

UI pushAPI Gateway

UIServer-SentEvents

Business Logic

Local data

API

BusinessEvents

Page 17: Event-Driven UI

17

CONFERENCEREGISTRATIONEXAMPLE submit

registrationform

RegistrationService

frontend

backend

NotificationService

MentorMatchingService

email toorganizing team

email toparticipant

...

...

Server-Sent Events

Participantregistered

Mentor assigned

github.com/mmacai/openslava-2019-rig-example

Page 18: Event-Driven UI

18

ANOTHER EXAMPLE..

github.com/kevinbader/rig-logistics-demo

Page 19: Event-Driven UI

19

Page 20: Event-Driven UI

20

Page 21: Event-Driven UI

21

Page 22: Event-Driven UI

22

Page 23: Event-Driven UI

23

Page 24: Event-Driven UI

24

Page 25: Event-Driven UI

25

Page 26: Event-Driven UI

26

Page 27: Event-Driven UI

27

Page 28: Event-Driven UI

28

Page 29: Event-Driven UI

29

SHOW ME THE CODE

github.com/kevinbader/rig-logistics-demo

Page 30: Event-Driven UI

Amazon Kinesis

• Real-time data feed• Via Server-Sent Events (HTTP/2 + HTTP/1.1)

• Via WebSocket (HTTP/1.1)

• Via HTTP long-polling

• Connection/session handling• Scalable in #users and #events

• Authorization: JSON web token, blacklisting

• HTTP reverse proxy• To HTTP endpoints and Kafka topics

WHAT CAN RIG DO?

30

Server-Sent Events

WebSocket

HTTP long-polling

Page 31: Event-Driven UI

31

MESSAGE FLOW

K8s Service

Consumer Group

Apache KafkaAmazon Kinesis

Kafka partitions / Kinesis shards

Server-Sent Events (HTTP/2)WebSocket (HTTP/1.1)

K8s headless servicefor peer discovery

HTTP long-polling

Page 32: Event-Driven UI

• CNCF spec• Simple envelope format• Encoding: JSON, Avro, ...• Mappings for transports:

Kafka, AMQP, MQTT, ...

CloudEvents

32

Page 33: Event-Driven UI

• Asynchronous, event-driven processing is the new default

• Decoupling: easy to add/remove microservices

• Deployment: easy to deal with upgrades/rollbacks/downtime

• But: frontend and 3rd party clients often expect immediate response

• Requires “conversion” of asynchronously processed result into synchronous request-response

SYNC REQUEST, ASYNC PROCESSING

33

Page 34: Event-Driven UI

34

HTTP POST

produce request event

pick up request event

process request

publish response

publish response

HTTP response

frontend message broker backend service

the frontend seesa traditional API

while processing is asynchronous

Page 35: Event-Driven UI

• 13 min

© 2019 Accenture

tl;dr

Page 36: Event-Driven UI

• Use live updates for great UX• Leverage events to decouple frontend and backend• Rely on open standards• Enable statelessness by handling connections at one place

GO BUILD EVENT-DRIVEN FRONTENDS!

37

Accenture/reactive-interaction-gatewayhttps://github.com/kevinbader/rig-logistics-demo