SlideShare uma empresa Scribd logo
1 de 33
Don’t Wait!
Develop responsive applications with Java EE7 instead!
Erin Schnabel
schnabel@us.ibm.com
@ebullientworks
Focus on the server side
• “Responsive” application
• Maximize resource utilization
• Technologies in EE7 can help
JAX-RS 2.0 async processing
Concurrency Utilities (JSR-236)
WebSocket API (JSR-356)
Non-blocking I/O added in Servlet 3.1
2
JAX-RS 2.0 Async Support
Concurrency Utilities
REST application (client-server or server-server)
4
NativeNative
HTML5
Front-End
REST
API
REST
API
**
Service B
Business
Logic
**
**
Service B
Business
Logic
**HybridHybrid
Service A
A (very) simple JAX-RS example
5
@Path(”items")
public class ItemResource {
// various ways to get this guy, play nice and assume we have one
protected ItemService itemService;
@GET
@Produces(MediaType.APPLICATION_JSON)
public Collection<Item> listItems() {
return itemService.listItems();
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void addItem(Item item) {
itemService.addItem(item);
}
...
}
A (very) simple JAX-RS example
6
@Path(”items")
public class ItemResource {
// various ways to get this guy, play nice and assume we have one
protected ItemService itemService;
@GET
@Produces(MediaType.APPLICATION_JSON)
public Collection<Item> listItems() {
return itemService.listItems();
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void addItem(Item item) {
itemService.addItem(item);
}
...
}
What if this is an
encapsulation of a
remote service?
What if this is an
encapsulation of a
remote service?
JAX-RS 2.0 Asynchronous processing
7
@GET
@Produces(MediaType.APPLICATION_JSON)
public void getItems(@Suspended final AsyncResponse ar) {
Collection<Item> result = itemService.listItems();
ar.resume(result );
}
• AsyncResponse.resume(…) to send the response to the client.
• @Suspended annotation with AsyncResponse parameter
• void return type (to allow this method to return immediately)
• “suspend” the connection -- NOT DISCONNECTED!
JAX-RS 2.0 Asynchronous processing
8
@GET
@Produces(MediaType.APPLICATION_JSON)
public void getItems(@Suspended final AsyncResponse ar) {
Collection<Item> result = itemService.listItems();
ar.resume(result );
}
• AsyncResponse.resume(…) to send the response to the client.
• @Suspended annotation with AsyncResponse parameter
• void return type (to allow this method to return immediately)
• “suspend” the connection -- NOT DISCONNECTED!
Hmm…I don’t see any
threading stuff. How is this
asynchronous?
Hmm…I don’t see any
threading stuff. How is this
asynchronous?
JAX-RS 2.0 and …
9
@GET
@Produces(MediaType.APPLICATION_JSON)
public void getItems(@Suspended final AsyncResponse ar) {
Runnable r = () -> {
Collection<Item> result = itemService.listItems();
Response resp = Response.ok(result).build();
ar.resume(resp);
};
Executors.newSingleThreadExecutor().submit(r);
}
This would totally work:
The long-running operation is
definitely on a different thread.
This would totally work:
The long-running operation is
definitely on a different thread.
Hopefully we also know that this
is a horrible idea!
#notcontainerfriendly
Hopefully we also know that this
is a horrible idea!
#notcontainerfriendly
JAX-RS 2.0 and EJB
• For a local EJB, use the @Asynchronous method annotation.
10
The EJB Container will
dispatch to a different thread
before invoking the method.
The EJB Container will
dispatch to a different thread
before invoking the method.
JAX-RS 2.0 and Concurrency Utilities
11
@Path("execitems")
public class ItemsExecutorResource {
private ExecutorService getExecutor() throws NamingException {
return (ExecutorService) new InitialContext()
.lookup("java:comp/DefaultManagedExecutorService");
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public void getItems(@Suspended final AsyncResponse ar) {
Runnable r = () -> {...};
try {
ExecutorService executor = getExecutor();
executor.submit(r);
} catch (NamingException e) {
r.run();
}
}
...
}
JNDI lookup for
managed executor
#oldschool
JNDI lookup for
managed executor
#oldschool
JAX-RS 2.0, CDI, and Concurrency Utilities
• Enable CDI (beans.xml), and have an Executor provided
12
JAX-RS 2.0: Time out!
13
JAX-RS 2.0: Callbacks
• Register callbacks on AsyncResponse:
14
Support for
ConnectionCallback is
optional.
#YMMV
Support for
ConnectionCallback is
optional.
#YMMV
Concurrency Utilities
• Extension of java.util.concurrent (familiar API)
– ManagedExecutorService
java:comp/DefaultManagedExecutorService
– ManagedScheduledExecutorService
java:comp/DefaultManagedScheduledExecutorService
– ManagedThreadFactory
java:comp/DefaultManagedThreadFactory
– ContextService
java:comp/DefaultContextService
• Container-friendly mechanisms to queue and manage work
– Java EE Context propagation
• JNDI, classloader, security, etc.
– Allows container to manage async work, too!
15
WebSocket APIs
Server Endpoint: Annotated
• Simple POJO with @ServerEndpoint annotation
• Annotations for notifications: lifecycle and messages
17
@ServerEndpoint(value = "/SimpleAnnotated")
public class SimpleEndpoint {
@OnOpen
public void onOpen(Session session, EndpointConfig ec) {
}
@OnClose
public void onClose(Session session, CloseReason reason) {
}
@OnMessage
public void receiveMessage(String message, Session session) {
}
@OnError
public void onError(Throwable t) {
}
}
• @OnMessage method is called when a message is received
– If message is ‘stop’: close the session
– Otherwise, echo the message along with a hit count
• Broadcast – iterate over open sessions
18
Simple echo + server provided data (using annotations)
Non-blocking I/O
Servlet 3.1
Non-blocking I/O in Servlet 3.1
• Builds on Asynchronous processing from Servlet 3.0
– Only works for async-enabled apps
• Enables reading/writing data without blocking a thread
– ReadListener on ServletInputStream
– WriteListener on ServletOutputStream
• Best used with slow clients
– For clients that are slow to read data, use a WriteListener
– For clients that are slow to write data, use a ReadListener
20
Code Samples – Aync Servlet Listener
21
// start async
AsyncContext ac = request.startAsync();
// set up async listener
ac.addListener(new AsyncListener() {
@Override
public void onComplete(AsyncEvent event) throws IOException {
System.out.println("AsyncServlet onComplete() called");
}
@Override
public void onError(AsyncEvent event) {
System.out.println("AsyncServlet onError() " + event.getThrowable());
}
@Override
public void onStartAsync(AsyncEvent event) {
System.out.println("AsyncServlet onStartAsync()");
}
@Override
public void onTimeout(AsyncEvent event) {
System.out.println("AsyncServlet onTimeout()");
}
}, request, response);
Code Samples – Non-Blocking I/O: Input
22
Code Samples – Non-Blocking I/O: Output
23
RxJava + EE7
Reactive Programming
• Reactive programming focuses on data flows and propagation of
change.
• Java 8 has introduced lambdas and a new java.util.stream package,
which help reactive programmers get started.
• For highly concurrent stream processing and more advanced
scenarios, ReactiveX is the library of choice.
• RxJava is the Java implementation of ReactiveX.
25
RxJava and JEE7
• RxJava and EE7 go hand-in-hand:
– Inject (CDI) and ExecutorServices from Concurrency Utilities into your app
– Encapsulate these concurrent artifacts with a RxJava Scheduler
– Use Websockets to provide real-time updates as observables are completed
26
RxJava and Liberty
• Applications deployed in Liberty can include the RxJava library and
seamlessly tap into its EE7 framework
27
RxJava and Liberty
• GitHub sample:
https://github.com/WASdev/sample.rxjava
• App provides reviews and weather information about vacation
destinations
– concurrent-1.0
– websocket-1.1
– cdi-1.2
28
RxJava and Liberty
29
RxJava and Liberty
30
Notices and Disclaimers
31
Copyright © 2016 by International Business Machines Corporation (IBM). No part of this document may be reproduced or transmitted in any form without written permission
from IBM.
U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM.
Information in these presentations (including information relating to products that have not yet been announced by IBM) has been reviewed for accuracy as of the date of
initial publication and could include unintentional technical or typographical errors. IBM shall have no responsibility to update this information. THIS DOCUMENT IS
DISTRIBUTED "AS IS" WITHOUT ANY WARRANTY, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL IBM BE LIABLE FOR ANY DAMAGE ARISING FROM THE
USE OF THIS INFORMATION, INCLUDING BUT NOT LIMITED TO, LOSS OF DATA, BUSINESS INTERRUPTION, LOSS OF PROFIT OR LOSS OF OPPORTUNITY. IBM
products and services are warranted according to the terms and conditions of the agreements under which they are provided.
Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without notice.
Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are presented as illustrations of how those
customers have used IBM products and the results they may have achieved. Actual performance, cost, savings or other results in other operating environments may vary.
References in this document to IBM products, programs, or services does not imply that IBM intends to make such products, programs or services available in all countries
in which IBM operates or does business.
Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not necessarily reflect the views of IBM. All materials
and discussions are provided for informational purposes only, and are neither intended to, nor shall constitute legal or other guidance or advice to any individual participant
or their specific situation.
It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal counsel as to the identification and
interpretation of any relevant laws and regulatory requirements that may affect the customer’s business and any actions the customer may need to take to comply with such
laws. IBM does not provide legal advice or represent or warrant that its services or products will ensure that the customer is in compliance with any law
Notices and Disclaimers Con’t.
32
Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not
tested those products in connection with this publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products.
Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. IBM does not warrant the quality of any third-party products, or the
ability of any such third-party products to interoperate with IBM’s products. IBM EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The provision of the information contained h erein is not intended to, and does not, grant any right or license under any IBM patents, copyrights, trademarks or other
intellectual property right.
IBM, the IBM logo, ibm.com, Aspera®, Bluemix, Blueworks Live, CICS, Clearcase, Cognos®, DOORS®, Emptoris®, Enterprise Document Management System™, FASP®,
FileNet®, Global Business Services ®, Global Technology Services ®, IBM ExperienceOne™, IBM SmartCloud®, IBM Social Business®, Information on Demand, ILOG,
Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON, OpenPower, PureAnalytics™, PureApplication®, pureCluster™, PureCoverage®, PureData®,
PureExperience®, PureFlex®, pureQuery®, pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, Smarter Commerce®, SoDA, SPSS, Sterling Commerce®,
StoredIQ, Tealeaf®, Tivoli®, Trusteer®, Unica®, urban{code}®, Watson, WebSphere®, Worklight®, X-Force® and System z® Z/OS, are trademarks of International Business
Machines Corporation, registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM
trademarks is available on the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.
Thank You
Your Feedback is Important!
Access the InterConnect 2016 Conference Attendee
Portal to complete your session surveys from your
smartphone,
laptop or conference kiosk.

Mais conteúdo relacionado

Mais procurados

IBM Impact Session 2351 hybrid apps
IBM Impact Session 2351 hybrid appsIBM Impact Session 2351 hybrid apps
IBM Impact Session 2351 hybrid appsnick_garrod
 
ConnectorsForIntegration
ConnectorsForIntegrationConnectorsForIntegration
ConnectorsForIntegrationbthomps1979
 
Cloud native integration
Cloud native integrationCloud native integration
Cloud native integrationKim Clark
 
Securing the Automation of Application Deployment with UrbanCode Deploy
Securing the Automation of Application Deployment with UrbanCode DeploySecuring the Automation of Application Deployment with UrbanCode Deploy
Securing the Automation of Application Deployment with UrbanCode DeployIBM UrbanCode Products
 
Converting to the latest COBOL Compiler made simple with the right tools
Converting to the latest COBOL Compiler made simple with the right toolsConverting to the latest COBOL Compiler made simple with the right tools
Converting to the latest COBOL Compiler made simple with the right toolsDevOps for Enterprise Systems
 
Technical Introduction to IBM Integration Bus
Technical Introduction to IBM Integration BusTechnical Introduction to IBM Integration Bus
Technical Introduction to IBM Integration BusGeza Geleji
 
Tips for Developing and Testing IBM HATS Applications
Tips for Developing and Testing IBM HATS ApplicationsTips for Developing and Testing IBM HATS Applications
Tips for Developing and Testing IBM HATS ApplicationsStrongback Consulting
 
Adopting DevOps in a Hybrid Cloud Featuring UrbanCode Deploy with Bluemix
Adopting DevOps in a Hybrid Cloud Featuring UrbanCode Deploy with BluemixAdopting DevOps in a Hybrid Cloud Featuring UrbanCode Deploy with Bluemix
Adopting DevOps in a Hybrid Cloud Featuring UrbanCode Deploy with BluemixIBM UrbanCode Products
 
How to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power UserHow to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power UserStrongback Consulting
 
IBM Connect 2014 - AD206 - Build Apps Rapidly by Leveraging Services from IBM...
IBM Connect 2014 - AD206 - Build Apps Rapidly by Leveraging Services from IBM...IBM Connect 2014 - AD206 - Build Apps Rapidly by Leveraging Services from IBM...
IBM Connect 2014 - AD206 - Build Apps Rapidly by Leveraging Services from IBM...Niklas Heidloff
 
Extending uBuild and uDeploy with Plugins
Extending uBuild and uDeploy with PluginsExtending uBuild and uDeploy with Plugins
Extending uBuild and uDeploy with PluginsIBM UrbanCode Products
 
IBM DevOps Workshops at IBM InterConnect 2017
IBM DevOps Workshops at IBM InterConnect 2017IBM DevOps Workshops at IBM InterConnect 2017
IBM DevOps Workshops at IBM InterConnect 2017IBM DevOps
 
IBM Enterprise Social Solutions on Bluemix (XPages and Connections)
IBM Enterprise Social Solutions  on Bluemix (XPages and Connections)IBM Enterprise Social Solutions  on Bluemix (XPages and Connections)
IBM Enterprise Social Solutions on Bluemix (XPages and Connections)Niklas Heidloff
 
Microservices
MicroservicesMicroservices
MicroservicesPT.JUG
 
OOD Principles and Patterns
OOD Principles and PatternsOOD Principles and Patterns
OOD Principles and PatternsNguyen Tung
 
JiveWorld 2013 Developer Review - Atlassian JIRA in Jive 7 Integration - Purp...
JiveWorld 2013 Developer Review - Atlassian JIRA in Jive 7 Integration - Purp...JiveWorld 2013 Developer Review - Atlassian JIRA in Jive 7 Integration - Purp...
JiveWorld 2013 Developer Review - Atlassian JIRA in Jive 7 Integration - Purp...AppFusions
 
IBM Rational Developer for System z Quick Start Sales Presentation
IBM Rational Developer for System z Quick Start Sales PresentationIBM Rational Developer for System z Quick Start Sales Presentation
IBM Rational Developer for System z Quick Start Sales PresentationIBM Rational software
 
Overview of Eclipse technologies
Overview of Eclipse technologiesOverview of Eclipse technologies
Overview of Eclipse technologiesPT.JUG
 
Useful Design Patterns for Enterprise Applications with Java
Useful Design Patterns for Enterprise Applications with JavaUseful Design Patterns for Enterprise Applications with Java
Useful Design Patterns for Enterprise Applications with JavaPT.JUG
 

Mais procurados (20)

EVOLVE'15 | Enhance | Loyola Baskar | Cisco - Multi-tenancy AEM Architectur...
EVOLVE'15 |  Enhance | Loyola Baskar | Cisco -  Multi-tenancy AEM Architectur...EVOLVE'15 |  Enhance | Loyola Baskar | Cisco -  Multi-tenancy AEM Architectur...
EVOLVE'15 | Enhance | Loyola Baskar | Cisco - Multi-tenancy AEM Architectur...
 
IBM Impact Session 2351 hybrid apps
IBM Impact Session 2351 hybrid appsIBM Impact Session 2351 hybrid apps
IBM Impact Session 2351 hybrid apps
 
ConnectorsForIntegration
ConnectorsForIntegrationConnectorsForIntegration
ConnectorsForIntegration
 
Cloud native integration
Cloud native integrationCloud native integration
Cloud native integration
 
Securing the Automation of Application Deployment with UrbanCode Deploy
Securing the Automation of Application Deployment with UrbanCode DeploySecuring the Automation of Application Deployment with UrbanCode Deploy
Securing the Automation of Application Deployment with UrbanCode Deploy
 
Converting to the latest COBOL Compiler made simple with the right tools
Converting to the latest COBOL Compiler made simple with the right toolsConverting to the latest COBOL Compiler made simple with the right tools
Converting to the latest COBOL Compiler made simple with the right tools
 
Technical Introduction to IBM Integration Bus
Technical Introduction to IBM Integration BusTechnical Introduction to IBM Integration Bus
Technical Introduction to IBM Integration Bus
 
Tips for Developing and Testing IBM HATS Applications
Tips for Developing and Testing IBM HATS ApplicationsTips for Developing and Testing IBM HATS Applications
Tips for Developing and Testing IBM HATS Applications
 
Adopting DevOps in a Hybrid Cloud Featuring UrbanCode Deploy with Bluemix
Adopting DevOps in a Hybrid Cloud Featuring UrbanCode Deploy with BluemixAdopting DevOps in a Hybrid Cloud Featuring UrbanCode Deploy with Bluemix
Adopting DevOps in a Hybrid Cloud Featuring UrbanCode Deploy with Bluemix
 
How to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power UserHow to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power User
 
IBM Connect 2014 - AD206 - Build Apps Rapidly by Leveraging Services from IBM...
IBM Connect 2014 - AD206 - Build Apps Rapidly by Leveraging Services from IBM...IBM Connect 2014 - AD206 - Build Apps Rapidly by Leveraging Services from IBM...
IBM Connect 2014 - AD206 - Build Apps Rapidly by Leveraging Services from IBM...
 
Extending uBuild and uDeploy with Plugins
Extending uBuild and uDeploy with PluginsExtending uBuild and uDeploy with Plugins
Extending uBuild and uDeploy with Plugins
 
IBM DevOps Workshops at IBM InterConnect 2017
IBM DevOps Workshops at IBM InterConnect 2017IBM DevOps Workshops at IBM InterConnect 2017
IBM DevOps Workshops at IBM InterConnect 2017
 
IBM Enterprise Social Solutions on Bluemix (XPages and Connections)
IBM Enterprise Social Solutions  on Bluemix (XPages and Connections)IBM Enterprise Social Solutions  on Bluemix (XPages and Connections)
IBM Enterprise Social Solutions on Bluemix (XPages and Connections)
 
Microservices
MicroservicesMicroservices
Microservices
 
OOD Principles and Patterns
OOD Principles and PatternsOOD Principles and Patterns
OOD Principles and Patterns
 
JiveWorld 2013 Developer Review - Atlassian JIRA in Jive 7 Integration - Purp...
JiveWorld 2013 Developer Review - Atlassian JIRA in Jive 7 Integration - Purp...JiveWorld 2013 Developer Review - Atlassian JIRA in Jive 7 Integration - Purp...
JiveWorld 2013 Developer Review - Atlassian JIRA in Jive 7 Integration - Purp...
 
IBM Rational Developer for System z Quick Start Sales Presentation
IBM Rational Developer for System z Quick Start Sales PresentationIBM Rational Developer for System z Quick Start Sales Presentation
IBM Rational Developer for System z Quick Start Sales Presentation
 
Overview of Eclipse technologies
Overview of Eclipse technologiesOverview of Eclipse technologies
Overview of Eclipse technologies
 
Useful Design Patterns for Enterprise Applications with Java
Useful Design Patterns for Enterprise Applications with JavaUseful Design Patterns for Enterprise Applications with Java
Useful Design Patterns for Enterprise Applications with Java
 

Semelhante a Develop Responsive Apps with Java EE7

Don't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadDon't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadWASdev Community
 
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...Oracle Developers
 
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EECON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EEMasoud Kalali
 
MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!Vitor Oliveira
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideMohanraj Thirumoorthy
 
Java EE7
Java EE7Java EE7
Java EE7Jay Lee
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatientGrant Steinfeld
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5Gal Marder
 
Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018Oracle Developers
 
Coherence RoadMap 2018
Coherence RoadMap 2018Coherence RoadMap 2018
Coherence RoadMap 2018harvraja
 
Microservices Part 4: Functional Reactive Programming
Microservices Part 4: Functional Reactive ProgrammingMicroservices Part 4: Functional Reactive Programming
Microservices Part 4: Functional Reactive ProgrammingAraf Karsh Hamid
 
IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016Trayan Iliev
 
Raising ux bar with offline first design
Raising ux bar with offline first designRaising ux bar with offline first design
Raising ux bar with offline first designKyrylo Reznykov
 
OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7Bruno Borges
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2divzi1913
 
GlassFish BOF
GlassFish BOFGlassFish BOF
GlassFish BOFglassfish
 
Microservice Pattern Launguage
Microservice Pattern LaunguageMicroservice Pattern Launguage
Microservice Pattern LaunguageInho Kang
 
Adopt-a-jsr Mar 1 2017 JAX-RS update
Adopt-a-jsr Mar 1 2017 JAX-RS updateAdopt-a-jsr Mar 1 2017 JAX-RS update
Adopt-a-jsr Mar 1 2017 JAX-RS updatePavel Bucek
 
Node Session - 1
Node Session - 1Node Session - 1
Node Session - 1Bhavin Shah
 
Nt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNicole Gomez
 

Semelhante a Develop Responsive Apps with Java EE7 (20)

Don't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadDon't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 Instead
 
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
 
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EECON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
 
MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's Guide
 
Java EE7
Java EE7Java EE7
Java EE7
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatient
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5
 
Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018
 
Coherence RoadMap 2018
Coherence RoadMap 2018Coherence RoadMap 2018
Coherence RoadMap 2018
 
Microservices Part 4: Functional Reactive Programming
Microservices Part 4: Functional Reactive ProgrammingMicroservices Part 4: Functional Reactive Programming
Microservices Part 4: Functional Reactive Programming
 
IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016
 
Raising ux bar with offline first design
Raising ux bar with offline first designRaising ux bar with offline first design
Raising ux bar with offline first design
 
OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
GlassFish BOF
GlassFish BOFGlassFish BOF
GlassFish BOF
 
Microservice Pattern Launguage
Microservice Pattern LaunguageMicroservice Pattern Launguage
Microservice Pattern Launguage
 
Adopt-a-jsr Mar 1 2017 JAX-RS update
Adopt-a-jsr Mar 1 2017 JAX-RS updateAdopt-a-jsr Mar 1 2017 JAX-RS update
Adopt-a-jsr Mar 1 2017 JAX-RS update
 
Node Session - 1
Node Session - 1Node Session - 1
Node Session - 1
 
Nt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language Analysis
 

Último

A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 

Último (20)

A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 

Develop Responsive Apps with Java EE7

  • 1. Don’t Wait! Develop responsive applications with Java EE7 instead! Erin Schnabel schnabel@us.ibm.com @ebullientworks
  • 2. Focus on the server side • “Responsive” application • Maximize resource utilization • Technologies in EE7 can help JAX-RS 2.0 async processing Concurrency Utilities (JSR-236) WebSocket API (JSR-356) Non-blocking I/O added in Servlet 3.1 2
  • 3. JAX-RS 2.0 Async Support Concurrency Utilities
  • 4. REST application (client-server or server-server) 4 NativeNative HTML5 Front-End REST API REST API ** Service B Business Logic ** ** Service B Business Logic **HybridHybrid Service A
  • 5. A (very) simple JAX-RS example 5 @Path(”items") public class ItemResource { // various ways to get this guy, play nice and assume we have one protected ItemService itemService; @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Item> listItems() { return itemService.listItems(); } @POST @Consumes(MediaType.APPLICATION_JSON) public void addItem(Item item) { itemService.addItem(item); } ... }
  • 6. A (very) simple JAX-RS example 6 @Path(”items") public class ItemResource { // various ways to get this guy, play nice and assume we have one protected ItemService itemService; @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Item> listItems() { return itemService.listItems(); } @POST @Consumes(MediaType.APPLICATION_JSON) public void addItem(Item item) { itemService.addItem(item); } ... } What if this is an encapsulation of a remote service? What if this is an encapsulation of a remote service?
  • 7. JAX-RS 2.0 Asynchronous processing 7 @GET @Produces(MediaType.APPLICATION_JSON) public void getItems(@Suspended final AsyncResponse ar) { Collection<Item> result = itemService.listItems(); ar.resume(result ); } • AsyncResponse.resume(…) to send the response to the client. • @Suspended annotation with AsyncResponse parameter • void return type (to allow this method to return immediately) • “suspend” the connection -- NOT DISCONNECTED!
  • 8. JAX-RS 2.0 Asynchronous processing 8 @GET @Produces(MediaType.APPLICATION_JSON) public void getItems(@Suspended final AsyncResponse ar) { Collection<Item> result = itemService.listItems(); ar.resume(result ); } • AsyncResponse.resume(…) to send the response to the client. • @Suspended annotation with AsyncResponse parameter • void return type (to allow this method to return immediately) • “suspend” the connection -- NOT DISCONNECTED! Hmm…I don’t see any threading stuff. How is this asynchronous? Hmm…I don’t see any threading stuff. How is this asynchronous?
  • 9. JAX-RS 2.0 and … 9 @GET @Produces(MediaType.APPLICATION_JSON) public void getItems(@Suspended final AsyncResponse ar) { Runnable r = () -> { Collection<Item> result = itemService.listItems(); Response resp = Response.ok(result).build(); ar.resume(resp); }; Executors.newSingleThreadExecutor().submit(r); } This would totally work: The long-running operation is definitely on a different thread. This would totally work: The long-running operation is definitely on a different thread. Hopefully we also know that this is a horrible idea! #notcontainerfriendly Hopefully we also know that this is a horrible idea! #notcontainerfriendly
  • 10. JAX-RS 2.0 and EJB • For a local EJB, use the @Asynchronous method annotation. 10 The EJB Container will dispatch to a different thread before invoking the method. The EJB Container will dispatch to a different thread before invoking the method.
  • 11. JAX-RS 2.0 and Concurrency Utilities 11 @Path("execitems") public class ItemsExecutorResource { private ExecutorService getExecutor() throws NamingException { return (ExecutorService) new InitialContext() .lookup("java:comp/DefaultManagedExecutorService"); } @GET @Produces(MediaType.APPLICATION_JSON) public void getItems(@Suspended final AsyncResponse ar) { Runnable r = () -> {...}; try { ExecutorService executor = getExecutor(); executor.submit(r); } catch (NamingException e) { r.run(); } } ... } JNDI lookup for managed executor #oldschool JNDI lookup for managed executor #oldschool
  • 12. JAX-RS 2.0, CDI, and Concurrency Utilities • Enable CDI (beans.xml), and have an Executor provided 12
  • 13. JAX-RS 2.0: Time out! 13
  • 14. JAX-RS 2.0: Callbacks • Register callbacks on AsyncResponse: 14 Support for ConnectionCallback is optional. #YMMV Support for ConnectionCallback is optional. #YMMV
  • 15. Concurrency Utilities • Extension of java.util.concurrent (familiar API) – ManagedExecutorService java:comp/DefaultManagedExecutorService – ManagedScheduledExecutorService java:comp/DefaultManagedScheduledExecutorService – ManagedThreadFactory java:comp/DefaultManagedThreadFactory – ContextService java:comp/DefaultContextService • Container-friendly mechanisms to queue and manage work – Java EE Context propagation • JNDI, classloader, security, etc. – Allows container to manage async work, too! 15
  • 17. Server Endpoint: Annotated • Simple POJO with @ServerEndpoint annotation • Annotations for notifications: lifecycle and messages 17 @ServerEndpoint(value = "/SimpleAnnotated") public class SimpleEndpoint { @OnOpen public void onOpen(Session session, EndpointConfig ec) { } @OnClose public void onClose(Session session, CloseReason reason) { } @OnMessage public void receiveMessage(String message, Session session) { } @OnError public void onError(Throwable t) { } }
  • 18. • @OnMessage method is called when a message is received – If message is ‘stop’: close the session – Otherwise, echo the message along with a hit count • Broadcast – iterate over open sessions 18 Simple echo + server provided data (using annotations)
  • 20. Non-blocking I/O in Servlet 3.1 • Builds on Asynchronous processing from Servlet 3.0 – Only works for async-enabled apps • Enables reading/writing data without blocking a thread – ReadListener on ServletInputStream – WriteListener on ServletOutputStream • Best used with slow clients – For clients that are slow to read data, use a WriteListener – For clients that are slow to write data, use a ReadListener 20
  • 21. Code Samples – Aync Servlet Listener 21 // start async AsyncContext ac = request.startAsync(); // set up async listener ac.addListener(new AsyncListener() { @Override public void onComplete(AsyncEvent event) throws IOException { System.out.println("AsyncServlet onComplete() called"); } @Override public void onError(AsyncEvent event) { System.out.println("AsyncServlet onError() " + event.getThrowable()); } @Override public void onStartAsync(AsyncEvent event) { System.out.println("AsyncServlet onStartAsync()"); } @Override public void onTimeout(AsyncEvent event) { System.out.println("AsyncServlet onTimeout()"); } }, request, response);
  • 22. Code Samples – Non-Blocking I/O: Input 22
  • 23. Code Samples – Non-Blocking I/O: Output 23
  • 25. Reactive Programming • Reactive programming focuses on data flows and propagation of change. • Java 8 has introduced lambdas and a new java.util.stream package, which help reactive programmers get started. • For highly concurrent stream processing and more advanced scenarios, ReactiveX is the library of choice. • RxJava is the Java implementation of ReactiveX. 25
  • 26. RxJava and JEE7 • RxJava and EE7 go hand-in-hand: – Inject (CDI) and ExecutorServices from Concurrency Utilities into your app – Encapsulate these concurrent artifacts with a RxJava Scheduler – Use Websockets to provide real-time updates as observables are completed 26
  • 27. RxJava and Liberty • Applications deployed in Liberty can include the RxJava library and seamlessly tap into its EE7 framework 27
  • 28. RxJava and Liberty • GitHub sample: https://github.com/WASdev/sample.rxjava • App provides reviews and weather information about vacation destinations – concurrent-1.0 – websocket-1.1 – cdi-1.2 28
  • 31. Notices and Disclaimers 31 Copyright © 2016 by International Business Machines Corporation (IBM). No part of this document may be reproduced or transmitted in any form without written permission from IBM. U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM. Information in these presentations (including information relating to products that have not yet been announced by IBM) has been reviewed for accuracy as of the date of initial publication and could include unintentional technical or typographical errors. IBM shall have no responsibility to update this information. THIS DOCUMENT IS DISTRIBUTED "AS IS" WITHOUT ANY WARRANTY, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL IBM BE LIABLE FOR ANY DAMAGE ARISING FROM THE USE OF THIS INFORMATION, INCLUDING BUT NOT LIMITED TO, LOSS OF DATA, BUSINESS INTERRUPTION, LOSS OF PROFIT OR LOSS OF OPPORTUNITY. IBM products and services are warranted according to the terms and conditions of the agreements under which they are provided. Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without notice. Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual performance, cost, savings or other results in other operating environments may vary. References in this document to IBM products, programs, or services does not imply that IBM intends to make such products, programs or services available in all countries in which IBM operates or does business. Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not necessarily reflect the views of IBM. All materials and discussions are provided for informational purposes only, and are neither intended to, nor shall constitute legal or other guidance or advice to any individual participant or their specific situation. It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal counsel as to the identification and interpretation of any relevant laws and regulatory requirements that may affect the customer’s business and any actions the customer may need to take to comply with such laws. IBM does not provide legal advice or represent or warrant that its services or products will ensure that the customer is in compliance with any law
  • 32. Notices and Disclaimers Con’t. 32 Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products in connection with this publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. IBM does not warrant the quality of any third-party products, or the ability of any such third-party products to interoperate with IBM’s products. IBM EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The provision of the information contained h erein is not intended to, and does not, grant any right or license under any IBM patents, copyrights, trademarks or other intellectual property right. IBM, the IBM logo, ibm.com, Aspera®, Bluemix, Blueworks Live, CICS, Clearcase, Cognos®, DOORS®, Emptoris®, Enterprise Document Management System™, FASP®, FileNet®, Global Business Services ®, Global Technology Services ®, IBM ExperienceOne™, IBM SmartCloud®, IBM Social Business®, Information on Demand, ILOG, Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON, OpenPower, PureAnalytics™, PureApplication®, pureCluster™, PureCoverage®, PureData®, PureExperience®, PureFlex®, pureQuery®, pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, Smarter Commerce®, SoDA, SPSS, Sterling Commerce®, StoredIQ, Tealeaf®, Tivoli®, Trusteer®, Unica®, urban{code}®, Watson, WebSphere®, Worklight®, X-Force® and System z® Z/OS, are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.
  • 33. Thank You Your Feedback is Important! Access the InterConnect 2016 Conference Attendee Portal to complete your session surveys from your smartphone, laptop or conference kiosk.

Notas do Editor

  1. REST over HTTP is an incredibly popular transport RESTful interactions take place both between client devices, either in browsers or in web applications, or between individual services in the backend of a microservices application.
  2. JAX-RS annotations make creating a RESTful service easy and obvious.
  3. If you are submitting the async work via an executor, you can set a timeout, and optionally register a timeout handler. If a handler isn’t present, a ServiceUnavailableException will be thrown with status code 503. The TimeoutHandler is given the AsyncResponse as a parameter, which must still be resumed to send a response back to the client. The AsyncResponse can also be cancelled, with an accompanying indication of how long a client should wait before retrying. A cancelled AsyncResponse sends a 503 / Service Unvaliable response to the client.
  4. If you are submitting the async work via an executor, you can set a timeout, and optionally register a timeout handler. If a handler isn’t present, a ServiceUnavailableException will be thrown with status code 503. The TimeoutHandler is given the AsyncResponse as a parameter, which must still be resumed to send a response back to the client.
  5. Unmanaged threads and timers can cause problems for containers: they inhibit an app server’s ability to track and manage resources. Concurrency Utilities provided in EE7 extend the mechanisms java.util.concurrent to provide a familiar API to applications that allows easy creation of container-managed resources to support async activities. Java EE Concurrency utilities provide context propagation, so that new threads inherit the container thread context of the originating application component thread (which is important for referencing other EE).
  6. @OnMessage methods are single threaded for an endpoint… Note the broadcast! Easy as pie to send the same data around to different sessions. Also note that each connection will have it’s own Endpoint instance, but that instances can see each other through sessions: Endpoints are not thread safe, but Sessions are.
  7. Create a new stream from the input destination Map them into internal populated POJOs, using a custom scheduler / executor.
  8. Concat previous observable of destinations (from previous inputs) with current stream Sort the aggregated list of destinations Flatten the list of destination streams into a single stream Subscribe (ie: push results back to client via websocket) using a different scheduler / executor.