Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Microservices with WildFly Swarm - JavaSI 2016

1,264 views

Published on

This presentation explains the new challenges to be resolved with a Microservices Architecture and how the WildFly Swarm container & OpenShift/Kubernetes can address some of the patterns like running a lightweight JavaEE container, discover and load balance the services, inject the configuration of the services.

Published in: Technology
  • Be the first to comment

Microservices with WildFly Swarm - JavaSI 2016

  1. 1. Microservices with WildFly Swarm Charles Moulliard (@cmoulliard) 17 Oct 2016  
  2. 2. 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 cmoulliard@redhat.com
  3. 3. Agenda The Context: Microservices and Java EE WildFly Swarm: Concepts, Ideas & Mechanics Code and Demo Discussions and (hopefully) beer
  4. 4. Microservices  
  5. 5. … SOA …
  6. 6.   – Martin Fowler, ThoughtWorks
  7. 7. Mono to Micro
  8. 8. Example
  9. 9. Be more concrete
  10. 10.  
  11. 11.  
  12. 12.  
  13. 13. … & Java EE  
  14. 14. 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/
  15. 15. Perception
  16. 16. Stack of …..
  17. 17. Plus JVM
  18. 18. What I really need
  19. 19. WildFly Swarm  
  20. 20. 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 Hat umbrella
  21. 21. Just Enough App Server Use the API’s you want Include the capabilities you need Wrap it up for deployment
  22. 22. Uber Jar A single .jar file containing your application, the portions of WildFly required to support it, an internal Maven repository of dependencies, plus a shim to bootstrap it all
  23. 23. Fractions A well-defined collection of application capabilities. May map directly to a WildFly subsystem, or bring in external capabilities such as Netflix Ribbon.
  24. 24. What Fractions can do Enable WildFly subsystems (JAX-RS, Infinispan) Integrate additional system capabilities (Topology) Provide deployment (ribbon-webapp, jolokia) Alter deployment (keycloak)
  25. 25. Some Fractions
  26. 26. Convert Java EE App to use WildFly Swarm  
  27. 27. 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> ...
  28. 28. 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>
  29. 29. Building & running Build the maven module $mvncleanpackage $ls-latarget/your.jar Run your Swarm App $java-jartarget/your.jar $mvnwildfly-swarm:run
  30. 30. Demo  
  31. 31. Going beyond simple (and Java EE)  
  32. 32. Project stages logger: level:DEBUG swarm: port: offset:10 --- project: stage:production logger: level:INFO swarm: port: offset:100
  33. 33. Customize Swarm publicclassMySwarmApp{ publicstaticvoidmain(String[]args)throwsException{ Swarmswarm=newSwarm(false).withStageConfig("project-stages.yml"); swarm.fraction(newJAXRSFraction()) .fraction(newLoggingFraction()); //Startthecontainer&deploythefractions swarm.start().deploy();
  34. 34. Customize Fraction publicclassMySwarmApp{ publicstaticvoidmain(String[]args)throwsException{ Swarmswarm=newSwarm(); swarm.fraction( newLoggingFraction().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=newHashMap<>(); fileSpec.put("path",logFile); h.file(fileSpec); }).logger("br.org.sistemafieg.cliente",(l)->{ l.level(Level.INFO) .handler("FILE"); }));
  35. 35. Securing access publicclassMySwarmApp{ publicstaticvoidmain(String[]args)throwsException{ Swarmswarm=newSwarm(); swarm.start(); ... //Createthearchiveandregistertheresourcestobepackaged/scanned JAXRSArchivearchive=ShrinkWrap.create(JAXRSArchive.class); archive.as(Secured.class) .protect() .withRole("admin"); swarm.deploy(archive); (provided by Keycloak: OpenID, SAML, Social Login, OAuth, LDAP, Active Directory)
  36. 36. Demo  
  37. 37. WildFly Microservices Demo
  38. 38. Questions Twitter : @cmoulliard Demos  https://github.com/cmoulliard/swarm-openshift http://wildfly-swarm.io

×