demystifying microservices for java ee developers me on twitter! @ensode 1 ensode technology, llc ...

21
Follow me on Twitter! @ensode 1 Ensode Technology, LLC http://www.ensode.com Demystifying Microservices for Java EE Developers David R. Heffelfinger Ensode Technology, LLC http://www.ensode.com @ensode

Upload: dangxuyen

Post on 29-Mar-2018

222 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 1

Ensode Technology, LLChttp://www.ensode.com

Demystifying Microservices for Java EE Developers

David R. HeffelfingerEnsode Technology, LLChttp://www.ensode.com

@ensode

Page 2: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 2

Ensode Technology, LLChttp://www.ensode.com

About me

● David R. Heffelfinger– Independent consultant based in Fairfax, VA

– Author of several books on Java, Java EE and related technologies

– Frequent speaker at Java conferences

– Named one of 39 Java experts you should follow on Twitter: https://techbeacon.com/java-leaders-you-should-follow-twitter

Page 3: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 3

Ensode Technology, LLChttp://www.ensode.com

Session Outline

● What are microservices?● Can Java EE do microservices?● Migrating to microservices● Microservices Demo● Java EE 8, Java EE 9 and MicroProfile● Summary

Page 4: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 4

Ensode Technology, LLChttp://www.ensode.com

What are microservices?

● Architectural style– Code deployed in small, granular modules

– Low coupling, high cohesion

– RESTful web services

– Framework and programming language independent

Page 5: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 5

Ensode Technology, LLChttp://www.ensode.com

Can Java EE do microservices?● Many Java EE application server vendors

provide lightweight, embeddable application servers (e.g. Payara Micro)

● One application developed per instance of application server

● Several instances of the application server deployed to a server

Page 6: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 6

Ensode Technology, LLChttp://www.ensode.com

Can Java EE do microservices? (cont'd)● Some application servers allow the creation of

an “uber jar”● Lightweight application servers can be added to

a container image (i.e. Docker)– Applications can be deployed as thin wars, typically

a few kilobytes in size.

● Modern, lightweight Java EE application servers suitable for microservices development

Page 7: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 7

Ensode Technology, LLChttp://www.ensode.com

Microservices Advantages

● Smaller codebases● Microservices encourage good coding

practices– Low coupling, high cohesion

● Resilience● Scalability

Page 8: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 8

Ensode Technology, LLChttp://www.ensode.com

Microservices Disadvantages● Additional operational and tooling overhead● Increased debugging complexity● Distributed transactions may pose a challenge● Network latency● Potential for complex interdependencies● Susceptible to the fallacies of distributed

computing

Page 9: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 9

Ensode Technology, LLChttp://www.ensode.com

Migrating to microservices

● Should we migrate?– Do the benefits outweight the disadvantages?

– Are there pressing business requirements?

● A migration to microservices may not provide much value to end users

Page 10: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 10

Ensode Technology, LLChttp://www.ensode.com

Migrating to microservices(cont'd)● Iterative refactoring

– Refactor an existing application one module at a time

– Identify an existing module to refactor as a microservice

● Client code for the refactored module would invoke the refactored code via HTTP requests

– Identify a second module to refactor, then a third, etc, until the complete application has been refactored to follow the microservices architectural style

Page 11: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 11

Ensode Technology, LLChttp://www.ensode.com

Migrating to microservices(cont'd)● Partial refactoring

– Identify modules that may be reusable across applications

– Refactor those (and only those) modules as microservices

– Hybrid approach

Page 12: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 12

Ensode Technology, LLChttp://www.ensode.com

Migrating to microservices(cont'd)● Implement new requirements as

microservices● Existing code invokes the newly developed

microservices via HTTP requests● Hybrid approach

Page 13: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 13

Ensode Technology, LLChttp://www.ensode.com

Microservices Demo

Page 14: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 14

Ensode Technology, LLChttp://www.ensode.com

Java EE 8

● Java API for JSON Binding (JSON-B)– Automatically populate Java objects from JSON

– Automatically generate JSON from Java objects

● Java API for RESTful Web Services (JAX-RS) 2.1– JSON-B support

– Server Sent Events

– Improved CDI integration

– Security improvements

Page 15: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 15

Ensode Technology, LLChttp://www.ensode.com

Java EE 8 (cont'd)

● CDI 2.0– Observer ordering

– Asynchronous events

– Configurators for major Service Provider Interface (SPI) elements

Page 16: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 16

Ensode Technology, LLChttp://www.ensode.com

Java EE 8 (cont'd)

● Bean Validation 2.0– Support for Java SE 8 Date/Time API

– Ability to validate all members of a collection with a single annotation

– Repeatable annotation support

Page 17: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 17

Ensode Technology, LLChttp://www.ensode.com

Java EE 9

● Project Jigsaw support– Java EE dependencies declared as modules

● Circuit Breaker design pattern support for JAX-RS

● New Event API● NoSQL database support● New State Management API

Page 18: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 18

Ensode Technology, LLChttp://www.ensode.com

Microprofile

● Collaboration between application server vendors and JUGs– IBM

– Payara Services

– Red Hat

– Tomitribe

– London Java Community

– SouJava Brazilian JUG

Page 19: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 19

Ensode Technology, LLChttp://www.ensode.com

MicroProfile (cont'd)

● Does not compete with Java EE– “Feeds” the Java EE standard

● Currently supports JAX-RS, CDI, and JSON-P

● May come up with new APIs

Page 20: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 20

Ensode Technology, LLChttp://www.ensode.com

Summary

● Java EE is suitable for microservices– Java EE developers can leverage their

expertise

– Deploy Java EE compliant code to an embeddable application server

– Traditional Java EE applications can be partially or completely refactored to microservices

Page 21: Demystifying Microservices for Java EE Developers me on Twitter! @ensode 1 Ensode Technology, LLC  Demystifying Microservices for Java EE Developers David R. Heffelfinger

Follow me on Twitter! @ensode 21

Ensode Technology, LLChttp://www.ensode.com

Additional Resources

● Demystifying Microservices for Java EE Developers Guide: http://info.payara.fish/demystifying-microservices-for-java-ee-developers

● The Aquarium (Java EE 8/9 News): https://blogs.oracle.com/theaquarium/

● MicroProfile: https://microprofile.io/● Follow me on Twitter! @ensode