a hitchikers introduction 0 to vertx - eclipse49 hitchhikers introduction to vertx recap vertx is a...

50
BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH A Hitchikers Introduction to Vertx Anatole Tresch, Principal Consultant 0

Upload: others

Post on 20-May-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH

A Hitchikers Introduction to Vertx

Anatole Tresch, Principal Consultant

0

Page 2: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

2 Hitchhikers Introduction to Vertx

About me...

● Principal Consultant, Trivadis AG (Switzerland)● Star Spec Lead JSR 354● Open Source Enthusiast

● Twitter: @atsticks● [email protected][email protected]

Page 3: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

3 Hitchhikers Introduction to Vertx

Agenda

● Basics

● Networking

● Clustering

● Vertx Maven Plugin

● There is more...

Page 4: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

Vertx?Is that something

to eat?

Page 5: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

5 Hitchhikers Introduction to Vertx

Tool-kit

for reactive applications

on the JVM

Page 6: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

6 Hitchhikers Introduction to Vertx

● Vert.x is not a container.

● You use the components you like.

● You can combine Vert.x with all the other libraries

you like.

Toolbox

Page 7: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

7 Hitchhikers Introduction to Vertx

Reactive

Source: http://www.reactivemanifesto.org/

Page 8: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

8 Hitchhikers Introduction to Vertx

Core

● TCP/HTTP client and server, Datagram Sockets

● Event bus● Shared data● Periodic and delayed actions● Verticles● DNS client● File system access● HA and Clustering

Page 9: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

9 Hitchhikers Introduction to Vertx

Starting

Page 10: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

10 Hitchhikers Introduction to Vertx

The Eventloop

● Events are distributed by the event loop thread aka Reactor

● Vertx = Multi-Reactor (by default Cores*2)

● Don‘t block the event loop !!!

Page 11: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

11 Hitchhikers Introduction to Vertx

Running Blocking Code

Page 12: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

12 Hitchhikers Introduction to Vertx

The Event Bus

● The nervous system of Vert.x.

● One single event bus instance for every Vert.x instance.

● Allows different parts of your application to communicate.

● Can be bridged to support client side JavaScript.

● A distributed peer-to-peer messaging spanning multiple nodes and browsers.

● Publish/subscribe, point to point, and request-response messaging.

Page 13: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

13 Hitchhikers Introduction to Vertx

Registering Handlers to the Event Bus

Page 14: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

14 Hitchhikers Introduction to Vertx

Publishing Events on the Event Bus

Page 15: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

15 Hitchhikers Introduction to Vertx

Acknowledging Messages

Page 16: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

16 Hitchhikers Introduction to Vertx

Delivery Options

Page 17: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

17 Hitchhikers Introduction to Vertx

JSON Support

● Vertx comes with full JSON OOTB (based on Jackson Library)

● JSON can is by default support over the event bus

● JsonObject.encode()/JsonArray.encode() → String

Page 18: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

18 Hitchhikers Introduction to Vertx

High Availability

Verticles can be deployed with High Availability enabled:

Page 19: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

19 Hitchhikers Introduction to Vertx

Buffers

Page 20: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

20 Hitchhikers Introduction to Vertx

Verticles● Simple, scalable, actor-like deployment and concurrency model

● Not a strict actor-model implementation, but similar

● Entirely optional

Page 21: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

21 Hitchhikers Introduction to Vertx

Page 22: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

22 Hitchhikers Introduction to Vertx

Verticle Types

Page 23: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

23 Hitchhikers Introduction to Vertx

Deploying Verticles

Or you use references for VerticleFactories for polyglot support,,,

Page 24: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

24 Hitchhikers Introduction to Vertx

Timers and Delays

One shot timers:

Periodic timers:

Page 25: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

25 Hitchhikers Introduction to Vertx

Shared Data● Local shared maps

● Cluster-wide asynchronous maps

● Cluster-wide locks & counters (not shown)

Page 26: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

Networking

Page 27: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

27 Hitchhikers Introduction to Vertx

TCP Server

Page 28: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

28 Hitchhikers Introduction to Vertx

TCP Server Reading/Writing

Page 29: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

29 Hitchhikers Introduction to Vertx

TCP Client

Page 30: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

30 Hitchhikers Introduction to Vertx

HTTP Server

Page 31: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

31 Hitchhikers Introduction to Vertx

HTTP Client

Page 32: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

32 Hitchhikers Introduction to Vertx

Vertx Web

Provides more flexible support for writing web services.

Page 33: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

33 Hitchhikers Introduction to Vertx

Vertx Web – Basic Routing

Page 34: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

34 Hitchhikers Introduction to Vertx

Vertx Web – Rest Endpoint

Page 35: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

35 Hitchhikers Introduction to Vertx

Vertx Web – Rest Endpoint

Page 36: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

36 Hitchhikers Introduction to Vertx

Vertx CircuitBreaker

Page 37: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

37 Hitchhikers Introduction to Vertx

Vertx ServiceDiscovery

Page 38: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

38 Hitchhikers Introduction to Vertx

Vertx ServiceDiscovery – Provider Sample

Page 39: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

39 Hitchhikers Introduction to Vertx

Vertx ServiceDiscovery – Consumer Sample

Page 40: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

Clustering & HA

Page 41: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

41 Hitchhikers Introduction to Vertx

Clustering

Page 42: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

42 Hitchhikers Introduction to Vertx

High Availability

Page 43: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

Vertx Maven Plugin

Page 44: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

44 Hitchhikers Introduction to Vertx

Vertx Maven Plugin

Page 45: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

I want to see a demo.

Please give me more.

Page 46: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

46 Hitchhikers Introduction to Vertx

Not discussed...● Vertx CLI● MQTT Client/Server● Configuration● Metrics Support● Health-Checks● Shell● Test Support● Service Proxies● Openshift / Docker Tooling● JDBC● NoSql Support● Advanced:

● Code Generation, Language Bindings, etc

Page 47: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

47 Hitchhikers Introduction to Vertx

Demo Time ...

Page 48: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

Recap

Page 49: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

49 Hitchhikers Introduction to Vertx

Recap

● Vertx is a very flexible and modular toolkit

● It is rather leightweight (ca. 6 MB for something useful)

● It is polyglot, supporting a big range of languages

● It is amazing fast

● It supports all requirements of the reactive manifesto

● It sometimes can be a beast

● It requires Java 8+

● It is fun to work with

Page 50: A Hitchikers Introduction 0 to Vertx - Eclipse49 Hitchhikers Introduction to Vertx Recap Vertx is a very flexible and modular toolkit It is rather leightweight (ca. 6 MB for something

Hitchhikers Introduction to Vertx

A Hitchhikers Introduction to VertxAnatole TreschPrincipal Consultant

Tel. +41 58 459 53 [email protected]

Vertx: http://vertx.io

Vertx Maven Plugin: https://vmp.fabric8.io/

Reactive Manifesto: http://www.reactivemanifesto.org/