Top Banner
Microservices with WildFly Swarm Charles Moulliard (@cmoulliard) 17 Oct 2016
38

Microservices with WildFly Swarm - JavaSI 2016

Jan 09, 2017

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Microservices with WildFly Swarm - JavaSI 2016

Microservices withWildFly Swarm

Charles Moulliard (@cmoulliard)17 Oct 2016

 

Page 2: Microservices with WildFly Swarm - JavaSI 2016

Who

Coder, Architect

Red Hat Engineer : Architect/Project lead for Global Platform Team

Apache Camel, Fabric8, WildFly Swarm, JBoss Forge committer

Mountain Biker, Belgian Beer Fan

Blog:

Twitter:

Email:

http://cmoulliard.github.io

@cmoulliard

[email protected]

Page 3: Microservices with WildFly Swarm - JavaSI 2016

Agenda

The Context: Microservices and Java EE

WildFly Swarm: Concepts, Ideas & Mechanics

Code and Demo

Discussions and (hopefully) beer

Page 4: Microservices with WildFly Swarm - JavaSI 2016

Microservices

 

Page 5: Microservices with WildFly Swarm - JavaSI 2016

… SOA …

Page 6: Microservices with WildFly Swarm - JavaSI 2016

 

– Martin Fowler, ThoughtWorks

Page 7: Microservices with WildFly Swarm - JavaSI 2016

Mono to Micro

Page 8: Microservices with WildFly Swarm - JavaSI 2016

Example

Page 9: Microservices with WildFly Swarm - JavaSI 2016

Be more concrete

Page 10: Microservices with WildFly Swarm - JavaSI 2016

 

Page 11: Microservices with WildFly Swarm - JavaSI 2016

 

Page 12: Microservices with WildFly Swarm - JavaSI 2016

 

Page 13: Microservices with WildFly Swarm - JavaSI 2016

… & Java EE

 

Page 14: Microservices with WildFly Swarm - JavaSI 2016

Perspectives on JavaEE

A collection of (useful) API’s

Stack of Frameworks

Designed to support distributed apps

Is JavaEE Ready Microservices ?

Depends what JavaEE 8/9 spec will propose

Does it support Microservices patterns ?

New initiative emerges :

https://microprofile.io/

Page 15: Microservices with WildFly Swarm - JavaSI 2016

Perception

Page 16: Microservices with WildFly Swarm - JavaSI 2016

Stack of …..

Page 17: Microservices with WildFly Swarm - JavaSI 2016

Plus JVM

Page 18: Microservices with WildFly Swarm - JavaSI 2016

What I really need

Page 19: Microservices with WildFly Swarm - JavaSI 2016

WildFly Swarm

 

Page 20: Microservices with WildFly Swarm - JavaSI 2016

Intro

OSS Project sponsored by Red Hat

Compatriot of Wildfly Application Server

Support MicroProfile

Microservices ready

Part of a bigger system of interrelated projects under the JBoss / Red Hatumbrella

Page 21: Microservices with WildFly Swarm - JavaSI 2016

Just Enough App Server

Use the API’s you want

Include the capabilitiesyou need

Wrap it up for deployment

Page 22: Microservices with WildFly Swarm - JavaSI 2016

Uber Jar

A single .jar file containing yourapplication,

the portions of WildFly required tosupport it,

an internal Maven repository ofdependencies,

plus a shim to bootstrap it all

Page 23: Microservices with WildFly Swarm - JavaSI 2016

Fractions

A well-defined collection of application capabilities.

May map directly to a WildFly subsystem,

or bring in external capabilities such as Netflix Ribbon.

Page 24: Microservices with WildFly Swarm - JavaSI 2016

What Fractions can do

Enable WildFly subsystems (JAX-RS, Infinispan)

Integrate additional system capabilities (Topology)

Provide deployment (ribbon-webapp, jolokia)

Alter deployment (keycloak)

Page 25: Microservices with WildFly Swarm - JavaSI 2016

Some Fractions

Page 26: Microservices with WildFly Swarm - JavaSI 2016

Convert Java EE App touse WildFly Swarm

 

Page 27: Microservices with WildFly Swarm - JavaSI 2016

Adding Fraction to your build<dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>jaxrs</artifactId> </dependency> <dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>cdi</artifactId> </dependency> <dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>swagger</artifactId> </dependency> ...

Page 28: Microservices with WildFly Swarm - JavaSI 2016

Adding maven plugin<plugin> <groupId>org.wildfly.swarm</groupId> <artifactId>wildfly-swarm-plugin</artifactId> <version>${wildfly.swarm.version}</version> <configuration> <properties> <swarm.port.offset>200</swarm.port.offset> </properties> </configuration> <executions> <execution> <goals> <goal>package</goal> </goals> </execution> </executions> </plugin>

Page 29: Microservices with WildFly Swarm - JavaSI 2016

Building & running

Build the maven module

$ mvn clean package $ ls -la target/your.jar

Run your Swarm App

$ java -jar target/your.jar $ mvn wildfly-swarm:run

Page 30: Microservices with WildFly Swarm - JavaSI 2016

Demo

 

Page 31: Microservices with WildFly Swarm - JavaSI 2016

Going beyond simple(and Java EE)

 

Page 32: Microservices with WildFly Swarm - JavaSI 2016

Project stageslogger: level: DEBUG swarm: port: offset: 10 --- project: stage: production logger: level: INFO swarm: port: offset: 100

Page 33: Microservices with WildFly Swarm - JavaSI 2016

Customize Swarmpublic class MySwarmApp { public static void main(String[] args) throws Exception { Swarm swarm = new Swarm(false).withStageConfig("project-stages.yml"); swarm.fraction(new JAXRSFraction()) .fraction(new LoggingFraction()); // Start the container & deploy the fractions swarm.start().deploy();

Page 34: Microservices with WildFly Swarm - JavaSI 2016

Customize Fractionpublic class MySwarmApp { public static void main(String[] args) throws Exception { Swarm swarm = new Swarm(); swarm.fraction( new LoggingFraction().periodicSizeRotatingFileHandler("FILE", (h) -> { h.level(Level.INFO) .append(true) .suffix(".yyyy-MM-dd") .rotateSize("30m") .enabled(true) .encoding("UTF-8") .maxBackupIndex(2); Map<String, String> fileSpec = new HashMap<>(); fileSpec.put("path", logFile); h.file(fileSpec); }).logger("br.org.sistemafieg.cliente", (l) -> { l.level(Level.INFO) .handler("FILE"); }));

Page 35: Microservices with WildFly Swarm - JavaSI 2016

Securing accesspublic class MySwarmApp { public static void main(String[] args) throws Exception { Swarm swarm = new Swarm(); swarm.start(); ... // Create the archive and register the resources to be packaged/scanned JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class); archive.as(Secured.class) .protect() .withRole("admin"); swarm.deploy(archive);

(provided by Keycloak: OpenID, SAML, Social Login, OAuth, LDAP, ActiveDirectory)

Page 36: Microservices with WildFly Swarm - JavaSI 2016

Demo

 

Page 37: Microservices with WildFly Swarm - JavaSI 2016

WildFly Microservices Demo

Page 38: Microservices with WildFly Swarm - JavaSI 2016

Questions

Twitter : @cmoulliard

Demos https://github.com/cmoulliard/swarm-openshift

http://wildfly-swarm.io