SlideShare a Scribd company logo
REACTIVE
Message Driven
Responsive
REACTIVEPROGRAMMING
Message Driven
Responsive
REACTIVESYSTEM
Message Driven
Responsive
Resilient
Elastic
WHY REACTIVE SYSTEMS?
TYPICAL JAVA APP...
final String PID = ManagementFactory.getRuntimeMXBean().getName();
@RequestMapping(value = "/work", method = RequestMethod.GET)
public @ResponseBody String work(HttpServletResponse resp) {
resp.setContentType("text/plain");
resp.setCharacterEncoding("UTF-8");
return "Pi is: " + Pi.calculate(100_000_000);
}
@RequestMapping(value = "/", method = RequestMethod.GET)
public @ResponseBody String home(HttpServletResponse resp) {
resp.setContentType("text/plain");
resp.setCharacterEncoding("UTF-8");
return "Current PID: " + PID;
}
TYPICAL NODE APP...
var process = require('process');
var app = require('express')();
var pi = require('./pi');
app.get('/', function (req, res) {
res.send('Request served by ' + process.pid);
});
app.get('/work', function (req, res) {
res.send('Pi = (' + process.pid + ') ' + pi(100000000));
});
app.listen(8080, function () {
console.log('Pi server listening on port 8080!')
});
DEMO
TYPICAL VERT.X APP...
// Initial Setup //
final String PID = ManagementFactory
.getRuntimeMXBean().getName();
final Router app = Router.router(vertx);
// Reactive Trait: RESPONSIVE //
// responsive, even under high load this handler
// can respond to requests
app.get("/").handler(ctx -> {
ctx.response()
.putHeader("content-type", "text/plain")
// Reactive Trait: RESILIENT //
// resilient, in case of failure the system
// recovers
.end("Current PID: " + PID);
});
// Reactive Trait: MESSAGE DRIVEN //
app.get("/work").handler(ctx -> {
// message driven, events can cross boundaries
// using a message driven architecture
vertx.eventBus().send("pi", null, reply -> {
if (reply.failed()) {
ctx.fail(reply.cause());
} else {
ctx.response()
.putHeader("content-type", "text/plain")
.end("Pi = " + reply.result().body());
}
});
});
// Reactive Trait: ELASTIC //
// elastic we can deploy several consumers to
// scale the application
vertx.eventBus().consumer("pi", m -> {
// can mix blocking and non-blocking code
vertx.executeBlocking(
fut -> fut.complete(Pi.calculate(100000000)),
false,
fut -> m.reply(PID + ": " + fut.result()));
});
DEMO
REACTIVE APPLICATIONS
REACT.JS
Simplicity
Component Based Approach
Performance and Virtual DOM
Awesome for SEO
Testability/Developers tools
Bonus: Mobile apps with react native
REACT.JS
Simplicity
Component Based Approach
Performance and Virtual DOM
Awesome for SEO
Testability/Developers tools
Bonus: Mobile apps with react native
WITH VERT.X YOU CAN...
Run JS with your Java,Scala,Kotlin,Groovy,Ruby,etc...
Mix CPU intensive tasks with non CPU intensive
Call EventBus remote services as if they were local
drop Node.JS
VERT.X UNIVERSAL APP
// Initial Setup //
const Router = require("vertx-web-js/router")
const StaticHandler =
require("vertx-web-js/static_handler")
import React from 'react'
import {renderToString} from 'react-dom/server'
import {match, RouterContext} from 'react-router'
import routes from '../shared/components/routes'
const app = Router.router(vertx)
// Rest API (Similar to Express.JS) //
app.get('/api/post').handler((ctx) => {
ctx.response()
.putHeader("content-type", "application/json")
.end(JSON.stringify(posts))
})
app.get('/api/post/:id').handler((ctx) => {
const id = ctx.request().getParam('id')
const post = posts.filter(p => p.id == id)
if (post) {
ctx.response()
.putHeader(
"content-type", "application/json")
.end(JSON.stringify(post[0]))
} else {
ctx.fail(404)
}
})
// Mix React.JS with Vert.x //
app.get().handler((ctx) => {
match({
routes: routes,
location: ctx.request().uri()
}, (err, redirect, props) => {
if (err) {
ctx.fail(err.message);
} else if (redirect) {
ctx.response()
.putHeader("Location",
redirect.pathname + redirect.search)
.setStatusCode(302)
.end();
} else if (props) {
const routerContextWithData = (
<RouterContext
{...props}
createElement={(Component, props) => {
return <Component
posts={posts} {...props} />
}}
/>)
VERT.X UNIVERSAL APP
// Mix React.JS with Vert.x //
app.get().handler((ctx) => {
match({
routes: routes,
location: ctx.request().uri()
}, (err, redirect, props) => {
if (err) {
ctx.fail(err.message);
} else if (redirect) {
ctx.response()
.putHeader("Location",
redirect.pathname + redirect.search)
.setStatusCode(302)
.end();
} else if (props) {
const routerContextWithData = (
<RouterContext
{...props}
createElement={(Component, props) => {
return <Component
posts={posts} {...props} />
}}
/>)
// Render React.js without Node //
const appHtml =
renderToString(routerContextWithData)
ctx.response()
.putHeader("content-type", "text/html")
.end(`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Universal Blog</title>
</head>
<body>
<div id="app">${appHtml}</div>
<script
src="/bundle.js"></script>
</body>
</html>`)
} else {
ctx.next()
}
})
})
// Serve resources and start //
app.get().handler(StaticHandler.create().handle)
vertx.createHttpServer()
.requestHandler(app.accept).listen(8080)
DEMO
WHAT ABOUT MICROSERVICES?
IN YOUR VERT.X APP...
final Router router = Router.router(vertx);
// Allow events for the designated addresses
BridgeOptions sockjsConfig = new BridgeOptions()
.addInboundPermitted(new PermittedOptions().setAddress("greetings"))
.addOutboundPermitted(new PermittedOptions().setAddress("greetings"));
// Create the event bus bridge and add it to the router.
router
.route("/eventbus/*")
.handler(SockJSHandler.create(vertx).bridge(sockjsConfig));
router.route().handler(StaticHandler.create());
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
IN YOUR VERT.X APP (2)...
...
router.route().handler(StaticHandler.create());
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
EventBus eb = vertx.eventBus();
vertx.setPeriodic(500, t ->
eb.send("greetings",
new JsonObject().put("msg", "Greetings from Vert.x!")));
IN YOUR REACT APP...
import EventBus from 'vertx3-eventbus-client'
const eb = new EventBus(`//${window.location.host}/eventbus`)
class App extends React.Component {
constructor(props) {
super(props)
this.state = { messages: [] }
}
render() {
let listItems = this.state.messages.map(message => {
return ( <li>{ `${message}` }</li> )
})
return ( <div><ul>{listItems}</ul></div> )
}
IN YOUR REACT APP (2)...
...
class App extends React.Component {
...
componentWillMount() {
Rx.Observable
.create((observer) => {
eb.registerHandler('greetings', (err, msg) => {
observer.next(msg.body.msg);
});
})
.subscribe(message => {
this.state.messages.unshift(message);
this.setState({ messages: this.state.messages });
});
}
IN YOUR NODE APP...
var EventBus = require('vertx3-eventbus-client');
var eb = new EventBus('http://localhost:8080/eventbus');
eb.onerror = function (err) {
console.error(err);
};
eb.onopen = function () {
setInterval(function () {
eb.send('greetings', {msg: 'Hello from Node.js!'});
}, 500);
};
IN YOUR REACT APP (3)...
...
class App extends React.Component {
...
static sayHello(e) {
e.preventDefault();
eb.send('greetings', {msg: 'Hello from React.js!'})
}
render() {
return (
...
<button onClick={App.sayHello}>Say Hello!</button>
DEMO
YOU GET A THE FREE BOOK!
WHAT ABOUT CALLBACK HELL?
ASYNC CODE:
route().handler(ctx -> {
ctx.user().isAuthorized("READ", res -> {
db.getConnection(conn -> {
conn.query("select * from test", rs -> {
conn.close( v -> {
ctx.response.end(rs.encode());
});
});
});
});
});
RX TO THE RESCUE
route().handler(ctx -> {
ctx.user().rxIsAuthorized("READ")
.flatMap(r -> db.rxGetConnection(conn))
.flatMap(c -> c.rxQuery("select * from test"))
.doAfterTerminate(c::close)
.subscribe(rs -> ctx.response.end(rs.encode()));
});
OR WITH (JS) VERT.X APP...
route().handler(async (ctx) -> {
if (await ctx.user().isAuthorized("READ")) {
try {
let c = await db.getConnection()
let rs = await c.query("select * from test")
ctx.response.end(rs.encode())
} finally {
c.close()
}
}
});
OR WITH (VERT.X SYNC) VERT.X APP...
route().handler(fiberHandler(ctx -> {
if (awaitResult(h -> ctx.user().isAuthorized("READ", h))) {
try (SQLConnection conn = awaitResult(jdbc::getConnection)) {
ResultSet res =
awaitResult(h -> conn.query("select * from test", h));
ctx.response.end(rs.encode());
}
}
}));
REACTIVE ISFUN!
HOW DO I START?
Github
Twitter
Youtube
Book
http://vertx.io
https://groups.google.com/forum/#!forum/vertx
https://github.com/vert-x3
@vertx_project
https://www.youtube.com/vertx_project
https://t.co/m2w7puPba8
THE END
Thanks you!
Follow me on twitter
Visit my blog
Start your project
@jetdrone
http://jetdrone.xyz
http://jetdrone.xyz/vertx-starter

More Related Content

What's hot

"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "
FDConf
 
Designing applications with Redux
Designing applications with ReduxDesigning applications with Redux
Designing applications with Redux
Fernando Daciuk
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
Nikolaus Graf
 
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
Shengyou Fan
 
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
Shengyou Fan
 
Redux training
Redux trainingRedux training
Redux training
dasersoft
 
Retrofit
RetrofitRetrofit
Retrofit
Amin Cheloh
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJS
All Things Open
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
Remo Jansen
 
React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
Vinícius Ribeiro
 
Promises, Promises
Promises, PromisesPromises, Promises
Promises, Promises
Domenic Denicola
 
Redux Universal
Redux UniversalRedux Universal
Redux Universal
Nikolaus Graf
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & Tooling
Binary Studio
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
Stephan Schmidt
 
React redux
React reduxReact redux
React redux
Michel Perez
 
React и redux
React и reduxReact и redux
React, Flux and a little bit of Redux
React, Flux and a little bit of ReduxReact, Flux and a little bit of Redux
React, Flux and a little bit of Redux
Ny Fanilo Andrianjafy, B.Eng.
 
React & redux
React & reduxReact & redux
React & redux
Cédric Hartland
 
How to connect AngularJS to servers
How to connect AngularJS to serversHow to connect AngularJS to servers
How to connect AngularJS to servers
Carlos Morales
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
Ayush Sharma
 

What's hot (20)

"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "
 
Designing applications with Redux
Designing applications with ReduxDesigning applications with Redux
Designing applications with Redux
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
 
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
 
Redux training
Redux trainingRedux training
Redux training
 
Retrofit
RetrofitRetrofit
Retrofit
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJS
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
 
React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
 
Promises, Promises
Promises, PromisesPromises, Promises
Promises, Promises
 
Redux Universal
Redux UniversalRedux Universal
Redux Universal
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & Tooling
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
 
React redux
React reduxReact redux
React redux
 
React и redux
React и reduxReact и redux
React и redux
 
React, Flux and a little bit of Redux
React, Flux and a little bit of ReduxReact, Flux and a little bit of Redux
React, Flux and a little bit of Redux
 
React & redux
React & reduxReact & redux
React & redux
 
How to connect AngularJS to servers
How to connect AngularJS to serversHow to connect AngularJS to servers
How to connect AngularJS to servers
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
 

Similar to Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017

React native by example by Vadim Ruban
React native by example by Vadim RubanReact native by example by Vadim Ruban
React native by example by Vadim Ruban
Lohika_Odessa_TechTalks
 
RESTEasy
RESTEasyRESTEasy
Bringing order to the chaos! - Paulo Lopes - Codemotion Amsterdam 2018
Bringing order to the chaos! - Paulo Lopes - Codemotion Amsterdam 2018Bringing order to the chaos! - Paulo Lopes - Codemotion Amsterdam 2018
Bringing order to the chaos! - Paulo Lopes - Codemotion Amsterdam 2018
Codemotion
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
Tomáš Kypta
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
JBug Italy
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
Vadym Khondar
 
Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015
Morris Singer
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
Daniel Bryant
 
React 101
React 101React 101
React 101
Casear Chu
 
Backendless apps
Backendless appsBackendless apps
Backendless apps
Matteo Bonifazi
 
Managing State in React Apps with RxJS by James Wright at FrontCon 2019
Managing State in React Apps with RxJS by James Wright at FrontCon 2019Managing State in React Apps with RxJS by James Wright at FrontCon 2019
Managing State in React Apps with RxJS by James Wright at FrontCon 2019
DevClub_lv
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creators
George Bukhanov
 
React lecture
React lectureReact lecture
React lecture
Christoffer Noring
 
node.js practical guide to serverside javascript
node.js practical guide to serverside javascriptnode.js practical guide to serverside javascript
node.js practical guide to serverside javascriptEldar Djafarov
 
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
apidays
 
mobl
moblmobl
mobl
zefhemel
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
Boris Dinkevich
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
Elena Kolevska
 
Connect.js - Exploring React.Native
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Native
joshcjensen
 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
Marco Otte-Witte
 

Similar to Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017 (20)

React native by example by Vadim Ruban
React native by example by Vadim RubanReact native by example by Vadim Ruban
React native by example by Vadim Ruban
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
Bringing order to the chaos! - Paulo Lopes - Codemotion Amsterdam 2018
Bringing order to the chaos! - Paulo Lopes - Codemotion Amsterdam 2018Bringing order to the chaos! - Paulo Lopes - Codemotion Amsterdam 2018
Bringing order to the chaos! - Paulo Lopes - Codemotion Amsterdam 2018
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
 
React 101
React 101React 101
React 101
 
Backendless apps
Backendless appsBackendless apps
Backendless apps
 
Managing State in React Apps with RxJS by James Wright at FrontCon 2019
Managing State in React Apps with RxJS by James Wright at FrontCon 2019Managing State in React Apps with RxJS by James Wright at FrontCon 2019
Managing State in React Apps with RxJS by James Wright at FrontCon 2019
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creators
 
React lecture
React lectureReact lecture
React lecture
 
node.js practical guide to serverside javascript
node.js practical guide to serverside javascriptnode.js practical guide to serverside javascript
node.js practical guide to serverside javascript
 
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
 
mobl
moblmobl
mobl
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Connect.js - Exploring React.Native
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Native
 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
 

More from Codemotion

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Codemotion
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending story
Codemotion
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storia
Codemotion
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard Altwasser
Codemotion
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Codemotion
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Codemotion
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Codemotion
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Codemotion
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Codemotion
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Codemotion
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Codemotion
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Codemotion
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Codemotion
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Codemotion
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Codemotion
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Codemotion
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Codemotion
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Codemotion
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Codemotion
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Codemotion
 

More from Codemotion (20)

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending story
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storia
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard Altwasser
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017

  • 1.
  • 3.
  • 6.
  • 8. TYPICAL JAVA APP... final String PID = ManagementFactory.getRuntimeMXBean().getName(); @RequestMapping(value = "/work", method = RequestMethod.GET) public @ResponseBody String work(HttpServletResponse resp) { resp.setContentType("text/plain"); resp.setCharacterEncoding("UTF-8"); return "Pi is: " + Pi.calculate(100_000_000); } @RequestMapping(value = "/", method = RequestMethod.GET) public @ResponseBody String home(HttpServletResponse resp) { resp.setContentType("text/plain"); resp.setCharacterEncoding("UTF-8"); return "Current PID: " + PID; }
  • 9. TYPICAL NODE APP... var process = require('process'); var app = require('express')(); var pi = require('./pi'); app.get('/', function (req, res) { res.send('Request served by ' + process.pid); }); app.get('/work', function (req, res) { res.send('Pi = (' + process.pid + ') ' + pi(100000000)); }); app.listen(8080, function () { console.log('Pi server listening on port 8080!') });
  • 10.
  • 11. DEMO
  • 12. TYPICAL VERT.X APP... // Initial Setup // final String PID = ManagementFactory .getRuntimeMXBean().getName(); final Router app = Router.router(vertx); // Reactive Trait: RESPONSIVE // // responsive, even under high load this handler // can respond to requests app.get("/").handler(ctx -> { ctx.response() .putHeader("content-type", "text/plain") // Reactive Trait: RESILIENT // // resilient, in case of failure the system // recovers .end("Current PID: " + PID); }); // Reactive Trait: MESSAGE DRIVEN // app.get("/work").handler(ctx -> { // message driven, events can cross boundaries // using a message driven architecture vertx.eventBus().send("pi", null, reply -> { if (reply.failed()) { ctx.fail(reply.cause()); } else { ctx.response() .putHeader("content-type", "text/plain") .end("Pi = " + reply.result().body()); } }); }); // Reactive Trait: ELASTIC // // elastic we can deploy several consumers to // scale the application vertx.eventBus().consumer("pi", m -> { // can mix blocking and non-blocking code vertx.executeBlocking( fut -> fut.complete(Pi.calculate(100000000)), false, fut -> m.reply(PID + ": " + fut.result())); });
  • 13. DEMO
  • 15. REACT.JS Simplicity Component Based Approach Performance and Virtual DOM Awesome for SEO Testability/Developers tools Bonus: Mobile apps with react native
  • 16. REACT.JS Simplicity Component Based Approach Performance and Virtual DOM Awesome for SEO Testability/Developers tools Bonus: Mobile apps with react native
  • 17.
  • 18. WITH VERT.X YOU CAN... Run JS with your Java,Scala,Kotlin,Groovy,Ruby,etc... Mix CPU intensive tasks with non CPU intensive Call EventBus remote services as if they were local drop Node.JS
  • 19. VERT.X UNIVERSAL APP // Initial Setup // const Router = require("vertx-web-js/router") const StaticHandler = require("vertx-web-js/static_handler") import React from 'react' import {renderToString} from 'react-dom/server' import {match, RouterContext} from 'react-router' import routes from '../shared/components/routes' const app = Router.router(vertx) // Rest API (Similar to Express.JS) // app.get('/api/post').handler((ctx) => { ctx.response() .putHeader("content-type", "application/json") .end(JSON.stringify(posts)) }) app.get('/api/post/:id').handler((ctx) => { const id = ctx.request().getParam('id') const post = posts.filter(p => p.id == id) if (post) { ctx.response() .putHeader( "content-type", "application/json") .end(JSON.stringify(post[0])) } else { ctx.fail(404) } }) // Mix React.JS with Vert.x // app.get().handler((ctx) => { match({ routes: routes, location: ctx.request().uri() }, (err, redirect, props) => { if (err) { ctx.fail(err.message); } else if (redirect) { ctx.response() .putHeader("Location", redirect.pathname + redirect.search) .setStatusCode(302) .end(); } else if (props) { const routerContextWithData = ( <RouterContext {...props} createElement={(Component, props) => { return <Component posts={posts} {...props} /> }} />)
  • 20. VERT.X UNIVERSAL APP // Mix React.JS with Vert.x // app.get().handler((ctx) => { match({ routes: routes, location: ctx.request().uri() }, (err, redirect, props) => { if (err) { ctx.fail(err.message); } else if (redirect) { ctx.response() .putHeader("Location", redirect.pathname + redirect.search) .setStatusCode(302) .end(); } else if (props) { const routerContextWithData = ( <RouterContext {...props} createElement={(Component, props) => { return <Component posts={posts} {...props} /> }} />) // Render React.js without Node // const appHtml = renderToString(routerContextWithData) ctx.response() .putHeader("content-type", "text/html") .end(`<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Universal Blog</title> </head> <body> <div id="app">${appHtml}</div> <script src="/bundle.js"></script> </body> </html>`) } else { ctx.next() } }) }) // Serve resources and start // app.get().handler(StaticHandler.create().handle) vertx.createHttpServer() .requestHandler(app.accept).listen(8080)
  • 21. DEMO
  • 22.
  • 24. IN YOUR VERT.X APP... final Router router = Router.router(vertx); // Allow events for the designated addresses BridgeOptions sockjsConfig = new BridgeOptions() .addInboundPermitted(new PermittedOptions().setAddress("greetings")) .addOutboundPermitted(new PermittedOptions().setAddress("greetings")); // Create the event bus bridge and add it to the router. router .route("/eventbus/*") .handler(SockJSHandler.create(vertx).bridge(sockjsConfig)); router.route().handler(StaticHandler.create()); vertx.createHttpServer().requestHandler(router::accept).listen(8080);
  • 25. IN YOUR VERT.X APP (2)... ... router.route().handler(StaticHandler.create()); vertx.createHttpServer().requestHandler(router::accept).listen(8080); EventBus eb = vertx.eventBus(); vertx.setPeriodic(500, t -> eb.send("greetings", new JsonObject().put("msg", "Greetings from Vert.x!")));
  • 26. IN YOUR REACT APP... import EventBus from 'vertx3-eventbus-client' const eb = new EventBus(`//${window.location.host}/eventbus`) class App extends React.Component { constructor(props) { super(props) this.state = { messages: [] } } render() { let listItems = this.state.messages.map(message => { return ( <li>{ `${message}` }</li> ) }) return ( <div><ul>{listItems}</ul></div> ) }
  • 27. IN YOUR REACT APP (2)... ... class App extends React.Component { ... componentWillMount() { Rx.Observable .create((observer) => { eb.registerHandler('greetings', (err, msg) => { observer.next(msg.body.msg); }); }) .subscribe(message => { this.state.messages.unshift(message); this.setState({ messages: this.state.messages }); }); }
  • 28. IN YOUR NODE APP... var EventBus = require('vertx3-eventbus-client'); var eb = new EventBus('http://localhost:8080/eventbus'); eb.onerror = function (err) { console.error(err); }; eb.onopen = function () { setInterval(function () { eb.send('greetings', {msg: 'Hello from Node.js!'}); }, 500); };
  • 29. IN YOUR REACT APP (3)... ... class App extends React.Component { ... static sayHello(e) { e.preventDefault(); eb.send('greetings', {msg: 'Hello from React.js!'}) } render() { return ( ... <button onClick={App.sayHello}>Say Hello!</button>
  • 30. DEMO
  • 31. YOU GET A THE FREE BOOK!
  • 33. ASYNC CODE: route().handler(ctx -> { ctx.user().isAuthorized("READ", res -> { db.getConnection(conn -> { conn.query("select * from test", rs -> { conn.close( v -> { ctx.response.end(rs.encode()); }); }); }); }); });
  • 34. RX TO THE RESCUE route().handler(ctx -> { ctx.user().rxIsAuthorized("READ") .flatMap(r -> db.rxGetConnection(conn)) .flatMap(c -> c.rxQuery("select * from test")) .doAfterTerminate(c::close) .subscribe(rs -> ctx.response.end(rs.encode())); });
  • 35. OR WITH (JS) VERT.X APP... route().handler(async (ctx) -> { if (await ctx.user().isAuthorized("READ")) { try { let c = await db.getConnection() let rs = await c.query("select * from test") ctx.response.end(rs.encode()) } finally { c.close() } } });
  • 36. OR WITH (VERT.X SYNC) VERT.X APP... route().handler(fiberHandler(ctx -> { if (awaitResult(h -> ctx.user().isAuthorized("READ", h))) { try (SQLConnection conn = awaitResult(jdbc::getConnection)) { ResultSet res = awaitResult(h -> conn.query("select * from test", h)); ctx.response.end(rs.encode()); } } }));
  • 38. HOW DO I START? Github Twitter Youtube Book http://vertx.io https://groups.google.com/forum/#!forum/vertx https://github.com/vert-x3 @vertx_project https://www.youtube.com/vertx_project https://t.co/m2w7puPba8
  • 39. THE END Thanks you! Follow me on twitter Visit my blog Start your project @jetdrone http://jetdrone.xyz http://jetdrone.xyz/vertx-starter