2. Who am I?
• Payara Engineer
• Java EE developer and lecturer
• Conference speaker
• Czech JUG leader
• Member of JCP and Eclipse foundation
• @omihalyi
3. What’s this all about?
• How lightweight is Java EE, really?
• What’s in Java EE 8 today?
• What could be in Java EE EE4J ??? in the future?
4. A little (recent) history...
• 12 June 2013: Java EE 7 Released
•Docker was 3 months old
•WildFly was still JBoss AS (and no Swarm)
•Before Spring Boot
•WebSphere Liberty Profile recently released
5. A little (recent) history...
• 21 September 2017: Java EE 8 Released, 4 years later
•Docker is now the dominant container format
•WildFly have fully product-ised WildFly Swarm
•Spring Boot have been making JARs not WARs for a few years
•IBM released Open Liberty
•Payara entered the fray and released Payara Micro
•Eclipse MicroProfile is established and progressing
6. What’s in Java EE 8?
• Upgrades
•JAX-RS 2.1
•Servlet 4.0
•Bean Validation 2.0
•JSF 2.3
•CDI 2.0
•JSON-P 1.1
• New
•Java EE Security
•JSON-B
7. What is Payara Micro?
• Payara Micro is…
•Micro! (~60MB disk size, ~30 MB RAM)
•Dynamically scalable
•Fully embeddable (if you want…)
•Web Profile “plus”
•On Maven Central
<dependency>
<groupId>fish.payara.api</groupId>
<ArtifactId>payara-api</artifactId>
<version>5.0.0-Alpha3</version>
<type>jar</type>
</dependency>
12. Demo 1
Creating the Stock Ticker
• What do we need?
• Stock object
• Stock Ticker to set the stock price
• Publisher for CDI event bus
13. Demo 2
Creating the Stock Web listener
• What do we need?
• Websocket endpoint
• Class to manage Websocket sessions
• Class to listen for Stock events on the CDI event bus
• Both these responsibilities can be in the same class
15. Demo
Making our MicroService generic
• What do we need to change?
• Non-Payara services can’t listen on the CDI event bus
• Solution: REST Server Sent Events (from JAX-RS 2.1)
• External services may not have access to a Stock object (or interface)
• Solution: Serialise our Stock object as JSON using JSON-B 1.0
19. Demo 4 SSE server endpoint in JAX-RS
@GET
@Produces(MediaType.SERVER_SENT_EVENTS)
public void eventOutput(@Context SseEventSink eventSink){
// send a single event
eventSink.send(sse.newEvent(stockTicker.getStock().toString()));
// registers the requester as a consumer of events
sseBroadcaster.register(eventSink);
}
@POST
@Path("broadcast")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void broadcast(@FormParam("event") String event){
// broadcasts the event to all registered consumers
sseBroadcaster.broadcast(sse.newEvent(event));
}
23. Demo 5
Integrating MicroProfile
// Set system property
java -jar -Dstockticker.url=http://localhost:8081/StockTicker-1.0-SNAPSHOT/rest/sse StockWeb/target/StockWeb-
1.0-SNAPSHOT-microbundle.jar
// Use asadmin to set property in Hazelcast cluster
asadmin> set-config-property
--propertyName=stockticker.url
--propertyValue=http://localhost:8080/StockTicker-1.0-SNAPSHOT/rest/sse
--source=cluster
// Use asadmin to set property for specific instances in Hazelcast cluster
asadmin> send-asadmin-command
--targets=‘*‘
--command=set-config-property
--
--propertyName=stockticker.url
--propertyValue=http://localhost:8080/StockTicker-1.0-SNAPSHOT/rest/sse
--source=config
--sourceName=sever-config
24. Recap
•Java EE is incredibly adaptable to changing needs
• Recent change has been driven by vendors’ implementations
• Eclipse MicroProfile offers interesting ideas for the future