With the growing challenges we face with shortage of resources there is a constant need to improve scalability and performance. Fortunately Java EE 7 and Java SE 7 has provided a rich set of APIs which can be used to avoid the conventional request-response paradigm. The session will span across JSRs cover how JAX-RS, Servlets, WebSockets, EJB provide support to submit asynchronous requests and cover topics like callbacks, timeouts, client side asynchrony, API like non blocking IO and lots of good stuff from Java EE 7 and Java SE 7 . Prerequisite: An open mind and be ready to “Think async”
Real world RESTful service development problems and solutionsBhakti Mehta
Learn all you ever wanted to learn about RESTful services development challenges in large scale applications
This session is a deep dive as well as an interactive discussion on design principles, considerations, lessons learned from mistakes that can be taken into account when developing RESTful services. It will cover a variety of topics from Designing of RESTful resources, Versioning, Exception Handling, Caching, Validation, Security, Rate limiting, HATEOAS, Testing and Documentation. This talk will walk through and compare the different REST API provided by companies like Twitter, Paypal, Google, Stripe and more we can learn the good, the bad and ugly. So join me in this talk to build high quality applications that can be highly scalable, available and reliable.
Mobile applications Development - Lecture 17
Server-Side Programming Primer:
REST
Web Sockets
Server-sent Events
This presentation has been developed in the context of the Mobile Applications Development course at the Computer Science Department of the University of L’Aquila (Italy).
http://www.di.univaq.it/malavolta
Getting Started with WebSocket and Server-Sent Events in JavaArun Gupta
This document discusses WebSocket and Server-Sent Events (SSE) in Java. It provides an overview of WebSocket including the handshake process and lifecycle. It also covers the Java API for creating WebSocket endpoints and handling messages. The document then discusses SSE and the EventSource JavaScript API. Finally, it compares WebSocket and SSE, noting their differences in capabilities and use cases.
ReST (Representational State Transfer) ExplainedDhananjay Nene
The document provides an overview of Representational State Transfer (REST), which is an architectural style for building distributed systems. It describes REST as a set of constraints or rules for designing web services, rather than a standard or framework. The key constraints outlined in the document include using a client-server model, being stateless, cacheable responses, a uniform interface, layered system, and code on demand. The document focuses on explaining the uniform interface constraint and its requirements around resource identification, manipulation through representations, self-descriptive messages, and hypermedia as the engine of application state.
Getting Started with WebSockets and Server-Sent EventsArun Gupta
This document discusses WebSocket and Server-Sent Events (SSE) for building interactive web applications. It provides an overview of WebSocket including how it enables full-duplex communication over a single TCP connection and the handshake process. It also discusses the Java API for WebSocket including annotated endpoints and custom payloads. Finally, it covers SSE, the EventSource API, and an example SSE implementation in Java.
This document provides an introduction to Java servlets and web technologies. It discusses HTTP protocols and methods like GET and POST. It explains concepts like web containers, servlet lifecycles, and the structure of web applications. It also provides instructions for setting up a servlet development environment with Java, Tomcat, and configuring the CLASSPATH variable. Finally, it outlines some important servlet API classes and interfaces.
This document provides an overview of servlets, including:
1. Servlets are Java programs that extend the functionality of web servers by dynamically processing HTTP requests and responses.
2. The life cycle of a servlet involves loading, instantiating, processing requests, and destroying.
3. Common steps to create and run a simple "Hello World" servlet using Tomcat include writing Java code, compiling, configuring deployment descriptors, and making HTTP requests.
4. Servlets offer benefits over other technologies like CGI scripts by being more efficient, persistent, portable, robust, and secure.
The document discusses the changes from HTTP/1.1 to HTTP/2, including multiplexing, server push, and priority. It notes that HTTP/2 was based on Google's SPDY experiment and aims to improve web performance. While HTTP/2 benefits some sites more than others, overall it helps reduce latency by allowing multiple requests over a single connection through header compression and other methods. However, factors like network latency still ultimately limit performance.
Real world RESTful service development problems and solutionsBhakti Mehta
Learn all you ever wanted to learn about RESTful services development challenges in large scale applications
This session is a deep dive as well as an interactive discussion on design principles, considerations, lessons learned from mistakes that can be taken into account when developing RESTful services. It will cover a variety of topics from Designing of RESTful resources, Versioning, Exception Handling, Caching, Validation, Security, Rate limiting, HATEOAS, Testing and Documentation. This talk will walk through and compare the different REST API provided by companies like Twitter, Paypal, Google, Stripe and more we can learn the good, the bad and ugly. So join me in this talk to build high quality applications that can be highly scalable, available and reliable.
Mobile applications Development - Lecture 17
Server-Side Programming Primer:
REST
Web Sockets
Server-sent Events
This presentation has been developed in the context of the Mobile Applications Development course at the Computer Science Department of the University of L’Aquila (Italy).
http://www.di.univaq.it/malavolta
Getting Started with WebSocket and Server-Sent Events in JavaArun Gupta
This document discusses WebSocket and Server-Sent Events (SSE) in Java. It provides an overview of WebSocket including the handshake process and lifecycle. It also covers the Java API for creating WebSocket endpoints and handling messages. The document then discusses SSE and the EventSource JavaScript API. Finally, it compares WebSocket and SSE, noting their differences in capabilities and use cases.
ReST (Representational State Transfer) ExplainedDhananjay Nene
The document provides an overview of Representational State Transfer (REST), which is an architectural style for building distributed systems. It describes REST as a set of constraints or rules for designing web services, rather than a standard or framework. The key constraints outlined in the document include using a client-server model, being stateless, cacheable responses, a uniform interface, layered system, and code on demand. The document focuses on explaining the uniform interface constraint and its requirements around resource identification, manipulation through representations, self-descriptive messages, and hypermedia as the engine of application state.
Getting Started with WebSockets and Server-Sent EventsArun Gupta
This document discusses WebSocket and Server-Sent Events (SSE) for building interactive web applications. It provides an overview of WebSocket including how it enables full-duplex communication over a single TCP connection and the handshake process. It also discusses the Java API for WebSocket including annotated endpoints and custom payloads. Finally, it covers SSE, the EventSource API, and an example SSE implementation in Java.
This document provides an introduction to Java servlets and web technologies. It discusses HTTP protocols and methods like GET and POST. It explains concepts like web containers, servlet lifecycles, and the structure of web applications. It also provides instructions for setting up a servlet development environment with Java, Tomcat, and configuring the CLASSPATH variable. Finally, it outlines some important servlet API classes and interfaces.
This document provides an overview of servlets, including:
1. Servlets are Java programs that extend the functionality of web servers by dynamically processing HTTP requests and responses.
2. The life cycle of a servlet involves loading, instantiating, processing requests, and destroying.
3. Common steps to create and run a simple "Hello World" servlet using Tomcat include writing Java code, compiling, configuring deployment descriptors, and making HTTP requests.
4. Servlets offer benefits over other technologies like CGI scripts by being more efficient, persistent, portable, robust, and secure.
The document discusses the changes from HTTP/1.1 to HTTP/2, including multiplexing, server push, and priority. It notes that HTTP/2 was based on Google's SPDY experiment and aims to improve web performance. While HTTP/2 benefits some sites more than others, overall it helps reduce latency by allowing multiple requests over a single connection through header compression and other methods. However, factors like network latency still ultimately limit performance.
Getting started with Websocket and Server-sent Events using Java - Arun Gupta jaxconf
Server-Sent Events defines a standard technology for server-push notifications. WebSocket attempts to solve the issues and limitations of HTTP for real-time communication by providing a full-duplex communication over a single TCP channel. Together, they bring new opportunities for efficient server-push and peer-to-peer communication, providing the basis for a new generation of interactive and “live” Web applications. This session provides a primer on WebSocket and Server-Sent Events and their supported use cases.
The document provides class notes on servlets by Dr. Vasanti Dutta. It discusses key topics related to servlets including what a servlet is, servlet features, the web application architecture, HTTP protocol basics, differences between static and dynamic websites, HTTP request methods, advantages of servlets over CGI, the servlet container and its functions, and interfaces in the servlet API such as ServletRequest.
1. The document discusses an FTP servlet, which acts as an intermediate application between FTP clients and servers. It helps distribute computing load from the FTP server to the servlet.
2. An FTP servlet wraps FTP traffic over HTTP or HTTPS for firewall friendliness and enhanced security. It processes client requests by overriding the service() method.
3. Using a generic servlet for FTP would make the servlet protocol independent. However, existing servlet containers do not support the FTP protocol at the connector level needed to implement this. The document explores using other protocols like WebDAV and SOAP with servlets as well.
Getting Started with WebSocket and Server-Sent Events using Java by Arun GuptaCodemotion
Server-Sent Events and WebSocket allow to write more interactive applications on web. It examines the efforts under way to support WebSocket in the Java programming model using JSR 356. The session also explains how Server-Sent Events can be easily written using Jersey, the Reference Implementation for JAX-RS 2. Simple “Hello World” to more elaborate Collaborative Whiteboard applications will show different features of both the technologies. A complete development using NetBeans, deployment on GlassFish, and debugging using Chrome will be shown.
HTTP is the protocol of the web, and in this session we will look at HTTP from a web developer's perspective. We will cover resources, messages, cookies, and authentication protocols and we will see how the web scales to meet demand using cache headers. Armed with the fundamentals about HTTP, you will have the knowledge not only to build better Web/Mobile applications but also for consuming Web API.
Web Server Technologies I: HTTP & Getting StartedPort80 Software
Introduction to HTTP: TCP/IP and application layer protocols, URLs, resources and MIME Types, HTTP request/response cycle and proxies. Setup and deployment: Planning Web server & site deployments, Site structure and basic server configuration, Managing users and hosts.
HTML5 Server Sent Events/JSF JAX 2011 ConferenceRoger Kitain
This document discusses server-sent events (SSE) for pushing data from servers to clients. It begins with an introduction to server-side push and strategies like client polling. It then explains SSE which allows a web page to subscribe to a stream of events from the server using a JavaScript API. The document demonstrates how to implement SSE on both the client-side and server-side. It also discusses how SSE can be used with JavaServer Faces (JSF) composite components to build rich, dynamic components that leverage two-way communication between client and server.
The never-ending REST API design debate -- Devoxx France 2016Restlet
The document discusses best practices for REST API design, including:
1) Using nouns instead of verbs for endpoints, and plural resource names instead of singular. It also recommends snake_case formatting.
2) Properly using HTTP status codes like 201 Created, 202 Accepted, 204 No Content, and providing helpful error responses.
3) Supporting features like pagination, filtering, sorting, searching, and caching responses with headers like ETag and Last-Modified.
4) Discussing approaches for API versioning in the URL, custom headers, or accept headers. The importance of hypermedia and discoverability is also emphasized.
Implementing Advanced Caching and Replication Techniques in ...webhostingguy
This document discusses implementing advanced caching and replication techniques in the Apache web server. Three new Apache modules were developed: mod_replication allows servers to track replicated documents and send invalidation messages when they change, mod_cgr upgrades proxy servers to replication servers and controls updating invalidated documents, and mod_wlis extracts replication server information from document headers and stores it in a database. The modules aim to improve document availability, reduce latency and traffic, and enable load balancing through caching and replication.
This document provides an overview of server-side web programming and different technologies used to create dynamic web pages, including Common Gateway Interface (CGI), servlets, and JavaServer Pages (JSP). CGI allows building dynamic web sites by running programs on the server that can generate HTML responses. Servlets provide a Java-based alternative to CGI with improved performance, portability, and security. Servlets use a request-response model and are executed by a servlet container. JSP is a technology that simplifies web page programming by mixing static elements like HTML with scripting code.
What is REST?
What is RESTful Webservices
HTTP-REST Request Basics
HTTP-REST Vocabulary
Authentication (OAuth)
OAuth 2.0 Web Server Flow
REST APIs using Apex REST
Resources
Simple REST-API overview for developers. An newer version is here: https://www.slideshare.net/patricksavalle/super-simple-introduction-to-restapis-2nd-version-127968966
1. The document introduces the World Wide Web and its core technologies including HTTP, HTML, web servers, and web browsers.
2. It describes how HTTP works using a request/response model and is stateless, while browser cookies allow for stateful sessions.
3. Examples demonstrate basic HTML pages and forms, HTTP requests and responses, and how dynamic content can be generated using server-side technologies like JSP.
Slides for my talk about designing good (or just good enough) Web APIs - https://hryniewski.net/great-web-apis-learn-how-to-make-one-in-45-minutesor-so/
The document discusses Common Gateway Interface (CGI) and its drawbacks. It then introduces Servlets as an alternative to CGI for creating dynamic web content. Servlets avoid the performance issues of CGI by running within a Java Virtual Machine on the server and supporting multi-threading. The document covers the servlet lifecycle, API, deployment, and other features that make servlets faster and more scalable than CGI for building web applications.
This presentation gives a high level concepts and more of code to take a stab at developing a simple Restful server. I targeted people who would like to build a simple RESTFul server from scratch and experiment.
HTTP is a stateless protocol that uses a request/response model for communication. A client sends a request via a URL to a server, which responds with status codes and content. Common request methods include GET, POST, PUT, DELETE. Responses have status codes like 200 for success and 404 for not found. Caching of responses helps improve performance. HTTPS provides encryption for secure communication via SSL/TLS certificates.
.NET Core, ASP.NET Core Course, Session 19aminmesbahi
The document provides an introduction to ASP.NET Core Identity and OAuth 2.0 authorization. It discusses Identity topics like user registration, sign in, the database schema, and dependencies. It also covers OAuth concepts like roles, tokens, registering as a client, authorization flows, and security vulnerabilities. The document is an introduction and overview of key Identity and OAuth concepts for a .NET Core training course.
This document discusses various Enterprise Application Integration centric designs or approaches which may be considered as better practices, and have been implemented in the data acquisition platform at Nielsen. Targeted audience is tech leaders and architects working across the platform. There is a special focus on leveraging open source technologies where possible. Hoping that some of the material here can help fellow architects.
This document introduces classes for asynchronous I/O in Servlet 3.0 without exposing low-level I/O details. New classes include ServletFuture, ServletAsyncHandler, ServletRequestChannel, and ServletResponseChannel. ServletRequestChannel allows asynchronous and synchronous read operations from the request body, while ServletResponseChannel allows write operations to the response. Examples demonstrate asynchronous and synchronous reads and writes, with the request automatically suspended for asynchronous operations.
Expect the unexpected: Anticipate and prepare for failures in microservices b...Bhakti Mehta
Bhakti Mehta discusses strategies for building resilient microservices architectures. Mehta covers challenges like cascading failures and latency that can occur at scale. Techniques like circuit breakers, timeouts, retries, and bulkheading are presented to isolate failures and prevent them from spreading. Logging and metrics are also important for monitoring systems and identifying issues after deployment. The talk emphasizes anticipating failures through approaches like load testing and designing systems to automatically recover from failures.
Getting started with Websocket and Server-sent Events using Java - Arun Gupta jaxconf
Server-Sent Events defines a standard technology for server-push notifications. WebSocket attempts to solve the issues and limitations of HTTP for real-time communication by providing a full-duplex communication over a single TCP channel. Together, they bring new opportunities for efficient server-push and peer-to-peer communication, providing the basis for a new generation of interactive and “live” Web applications. This session provides a primer on WebSocket and Server-Sent Events and their supported use cases.
The document provides class notes on servlets by Dr. Vasanti Dutta. It discusses key topics related to servlets including what a servlet is, servlet features, the web application architecture, HTTP protocol basics, differences between static and dynamic websites, HTTP request methods, advantages of servlets over CGI, the servlet container and its functions, and interfaces in the servlet API such as ServletRequest.
1. The document discusses an FTP servlet, which acts as an intermediate application between FTP clients and servers. It helps distribute computing load from the FTP server to the servlet.
2. An FTP servlet wraps FTP traffic over HTTP or HTTPS for firewall friendliness and enhanced security. It processes client requests by overriding the service() method.
3. Using a generic servlet for FTP would make the servlet protocol independent. However, existing servlet containers do not support the FTP protocol at the connector level needed to implement this. The document explores using other protocols like WebDAV and SOAP with servlets as well.
Getting Started with WebSocket and Server-Sent Events using Java by Arun GuptaCodemotion
Server-Sent Events and WebSocket allow to write more interactive applications on web. It examines the efforts under way to support WebSocket in the Java programming model using JSR 356. The session also explains how Server-Sent Events can be easily written using Jersey, the Reference Implementation for JAX-RS 2. Simple “Hello World” to more elaborate Collaborative Whiteboard applications will show different features of both the technologies. A complete development using NetBeans, deployment on GlassFish, and debugging using Chrome will be shown.
HTTP is the protocol of the web, and in this session we will look at HTTP from a web developer's perspective. We will cover resources, messages, cookies, and authentication protocols and we will see how the web scales to meet demand using cache headers. Armed with the fundamentals about HTTP, you will have the knowledge not only to build better Web/Mobile applications but also for consuming Web API.
Web Server Technologies I: HTTP & Getting StartedPort80 Software
Introduction to HTTP: TCP/IP and application layer protocols, URLs, resources and MIME Types, HTTP request/response cycle and proxies. Setup and deployment: Planning Web server & site deployments, Site structure and basic server configuration, Managing users and hosts.
HTML5 Server Sent Events/JSF JAX 2011 ConferenceRoger Kitain
This document discusses server-sent events (SSE) for pushing data from servers to clients. It begins with an introduction to server-side push and strategies like client polling. It then explains SSE which allows a web page to subscribe to a stream of events from the server using a JavaScript API. The document demonstrates how to implement SSE on both the client-side and server-side. It also discusses how SSE can be used with JavaServer Faces (JSF) composite components to build rich, dynamic components that leverage two-way communication between client and server.
The never-ending REST API design debate -- Devoxx France 2016Restlet
The document discusses best practices for REST API design, including:
1) Using nouns instead of verbs for endpoints, and plural resource names instead of singular. It also recommends snake_case formatting.
2) Properly using HTTP status codes like 201 Created, 202 Accepted, 204 No Content, and providing helpful error responses.
3) Supporting features like pagination, filtering, sorting, searching, and caching responses with headers like ETag and Last-Modified.
4) Discussing approaches for API versioning in the URL, custom headers, or accept headers. The importance of hypermedia and discoverability is also emphasized.
Implementing Advanced Caching and Replication Techniques in ...webhostingguy
This document discusses implementing advanced caching and replication techniques in the Apache web server. Three new Apache modules were developed: mod_replication allows servers to track replicated documents and send invalidation messages when they change, mod_cgr upgrades proxy servers to replication servers and controls updating invalidated documents, and mod_wlis extracts replication server information from document headers and stores it in a database. The modules aim to improve document availability, reduce latency and traffic, and enable load balancing through caching and replication.
This document provides an overview of server-side web programming and different technologies used to create dynamic web pages, including Common Gateway Interface (CGI), servlets, and JavaServer Pages (JSP). CGI allows building dynamic web sites by running programs on the server that can generate HTML responses. Servlets provide a Java-based alternative to CGI with improved performance, portability, and security. Servlets use a request-response model and are executed by a servlet container. JSP is a technology that simplifies web page programming by mixing static elements like HTML with scripting code.
What is REST?
What is RESTful Webservices
HTTP-REST Request Basics
HTTP-REST Vocabulary
Authentication (OAuth)
OAuth 2.0 Web Server Flow
REST APIs using Apex REST
Resources
Simple REST-API overview for developers. An newer version is here: https://www.slideshare.net/patricksavalle/super-simple-introduction-to-restapis-2nd-version-127968966
1. The document introduces the World Wide Web and its core technologies including HTTP, HTML, web servers, and web browsers.
2. It describes how HTTP works using a request/response model and is stateless, while browser cookies allow for stateful sessions.
3. Examples demonstrate basic HTML pages and forms, HTTP requests and responses, and how dynamic content can be generated using server-side technologies like JSP.
Slides for my talk about designing good (or just good enough) Web APIs - https://hryniewski.net/great-web-apis-learn-how-to-make-one-in-45-minutesor-so/
The document discusses Common Gateway Interface (CGI) and its drawbacks. It then introduces Servlets as an alternative to CGI for creating dynamic web content. Servlets avoid the performance issues of CGI by running within a Java Virtual Machine on the server and supporting multi-threading. The document covers the servlet lifecycle, API, deployment, and other features that make servlets faster and more scalable than CGI for building web applications.
This presentation gives a high level concepts and more of code to take a stab at developing a simple Restful server. I targeted people who would like to build a simple RESTFul server from scratch and experiment.
HTTP is a stateless protocol that uses a request/response model for communication. A client sends a request via a URL to a server, which responds with status codes and content. Common request methods include GET, POST, PUT, DELETE. Responses have status codes like 200 for success and 404 for not found. Caching of responses helps improve performance. HTTPS provides encryption for secure communication via SSL/TLS certificates.
.NET Core, ASP.NET Core Course, Session 19aminmesbahi
The document provides an introduction to ASP.NET Core Identity and OAuth 2.0 authorization. It discusses Identity topics like user registration, sign in, the database schema, and dependencies. It also covers OAuth concepts like roles, tokens, registering as a client, authorization flows, and security vulnerabilities. The document is an introduction and overview of key Identity and OAuth concepts for a .NET Core training course.
This document discusses various Enterprise Application Integration centric designs or approaches which may be considered as better practices, and have been implemented in the data acquisition platform at Nielsen. Targeted audience is tech leaders and architects working across the platform. There is a special focus on leveraging open source technologies where possible. Hoping that some of the material here can help fellow architects.
This document introduces classes for asynchronous I/O in Servlet 3.0 without exposing low-level I/O details. New classes include ServletFuture, ServletAsyncHandler, ServletRequestChannel, and ServletResponseChannel. ServletRequestChannel allows asynchronous and synchronous read operations from the request body, while ServletResponseChannel allows write operations to the response. Examples demonstrate asynchronous and synchronous reads and writes, with the request automatically suspended for asynchronous operations.
Expect the unexpected: Anticipate and prepare for failures in microservices b...Bhakti Mehta
Bhakti Mehta discusses strategies for building resilient microservices architectures. Mehta covers challenges like cascading failures and latency that can occur at scale. Techniques like circuit breakers, timeouts, retries, and bulkheading are presented to isolate failures and prevent them from spreading. Logging and metrics are also important for monitoring systems and identifying issues after deployment. The talk emphasizes anticipating failures through approaches like load testing and designing systems to automatically recover from failures.
Resilience planning and how the empire strikes backBhakti Mehta
t is well said that "The more you sweat on the field, the less you bleed in war". Failures are an inevitable part of complex systems. Accepting that failures happen, will help you design the system's reactions to specific failures.
This talks on best practices for building resilient, stable and predictable services: preventing cascading failures, timeouts pattern, retry pattern,circuit breakers and other techniques which have been pervasively used at Blue Jeans Network. Join me in this talk which ensures that the show must go on in spite of random load, stress or other failures!
Con fess 2013-sse-websockets-json-bhaktiBhakti Mehta
This document provides an overview of several technologies for asynchronous communication between client and server: Server Sent Events (SSE), WebSockets, JSON-P, JAXRS 2.0, and AsyncServlet. It describes how SSE allows a server to push data to clients via an event stream, discusses the WebSocket protocol for full-duplex communication, and explains how JSON-P and JAXRS 2.0 support processing JSON on the Java platform. Code samples are provided for using these technologies. The document concludes by describing a demo application that integrates several of these techniques to asynchronously retrieve and display Twitter data.
This document provides tips for using the GlassFish application server. It begins with an introduction to GlassFish and outlines the goals of the session. The body contains over 30 tips covering a wide range of GlassFish topics from using the asadmin command to configuring clusters. Each tip is presented concisely in 1-2 paragraphs and includes code examples.
Architecting for Failures in micro services: patterns and lessons learnedBhakti Mehta
This document provides an overview of architecting microservices for failures based on the presenter's experience. It discusses the path from monoliths to microservices, challenges that emerge at scale including failures, and lessons learned for making systems resilient. The presentation covers failure prevention patterns like circuit breakers, timeouts, retries, and bulkheads. It also discusses monitoring techniques like health checks, metrics, and phased rollouts for new features. The goal is to anticipate failures and design systems that can withstand transient errors and continue functioning.
Expect the unexpected: Prepare for failures in microservicesBhakti Mehta
My talk at Confoo 2016 Montreal
It is well said that "The more you sweat on the field, the less you bleed in war". Failures are an inevitable part of complex systems. Accepting that failures happen, will help you design the system's reactions to specific failures.
This talks on best practices for building resilient, stable and predictable services:
preventing Cascading failures, Timeouts pattern, Retry pattern,Circuit breakers
and many more techniques in microservices
Asynchronous Web Programming with HTML5 WebSockets and JavaJames Falkner
(Talk originally given @ KCDC - http://kcdc.info ).
Over the last decade, advances in web computing have removed many of the barriers to entry for developers. New languages, frameworks, and development methodologies have kickstarted new ideas and new ways to develop web applications to make modern life easier and more efficient. WebSockets (introduced as part of HTML5) is one such technology that enables a new class of scalable, super-responsive, collaborative, and real-time web applications with a wide range of uses.
In this talk, we will first cover the basics of asynchronous web programming using WebSockets, including predecessors such as polling and long-polling, applications of WebSockets, its limitations and potential bottlenecks, and potential future improvements.
Next, we will demo and dissect a real-world use case for realtime social data analytics, using the Apache Tomcat implementation of WebSockets and the Java-based Liferay Portal Server. This will include a discussion about development of WebSocket endpoints, its lifecycle within the application container and browser, debugging WebSockets, and scalability topics.
Building Next Generation Real-Time Web Applications using WebsocketsNaresh Chintalcheru
This document discusses real-time web applications and the technologies needed to enable them. It describes how HTTP is half-duplex and led to hacks like long polling to simulate real-time behavior. The WebSocket protocol provides full-duplex communications by upgrading the HTTP handshake. This allows real-time messaging over a single connection. The document also covers asynchronous programming, event-driven architectures, and frameworks like Spring that support WebSockets and asynchronous APIs.
Let if flow: Java 8 Streams puzzles and moreBhakti Mehta
This talk covers Java 8 Streams in details and using programming puzzles will discuss about various techniques with Streams: how to do complex data processing , queries with Streams API, how to use all the goodies like map, flatMap,filter, how to group, and partition data, how to use infinite streams, parallel streams, creating lazy lists.
If you are a beginner or a pro with Java 8 wanting to challenge your knowledge there is something for all!
The document discusses asynchronous programming in C# using tasks and async/await. It provides examples of using Task.Run to execute work asynchronously and await to wait for asynchronous tasks to complete. It also examines how async/await methods are desugared by the compiler into state machines behind the scenes.
in these slides i have explained the Observer design pattern. slides includes the complete definition, explanation and then implementation with code examples.
Akka persistence == event sourcing in 30 minutesKonrad Malawski
Akka 2.3 introduces akka-persistence, a wonderful way of implementing event-sourced applications. Let's give it a shot and see how DDD and Akka are a match made in heaven :-)
Oak, the architecture of Apache Jackrabbit 3Jukka Zitting
Apache Jackrabbit is just about to reach the 3.0 milestone based on a new architecture called Oak. Based on concepts like eventual consistency and multi-version concurrency control, and borrowing ideas from distributed version control systems and cloud-scale databases, the Oak architecture is a major leap ahead for Jackrabbit. This presentation describes the Oak architecture and shows what it means for the scalability and performance of modern content applications. Changes to existing Jackrabbit functionality are described and the migration process is explained.
Bhakti Mehta presented on architecting microservices for failures and lessons learned. Some key points include:
1) When developing microservices, techniques like circuit breakers, timeouts, retries, and rate limiting can help avoid cascading failures.
2) extensive testing including load testing and failure injection testing should be done before production deployment.
3) After deploying to production, continuous monitoring of metrics and health checks is important to quickly identify issues.
Based on the Star Wars theme, this session focuses on how Java EE 7 provides an extensive set of new and enhanced features to support standards such as HTML5, WebSocket, and Server-sent events, among others. The session shows how these new features are designed and matched to work together for developing lightweight solutions matching end users’ high expectations for Web application responsiveness. It covers best practices and design patterns associating the technologies with analogies from Star Wars. So join me in this fun filled talk where technology meets science and innovation..
May the force be with you!
WebSockets - Realtime em Mundo ConectadoBruno Borges
This document discusses WebSockets and the Java API for WebSockets. It provides an overview of the WebSocket protocol and browser support. It then describes the Java API specification JSR-356 and how to create WebSocket endpoints and handle events like messages using annotations or a programmatic API. It also covers security, the reference implementation Tyrus, and how WebLogic Server 12.1.3 supports Java EE 7 WebSockets including fallback options for environments without native WebSocket support.
The document discusses the need for web servers to provide various web services for a company. It provides an overview of the history and development of the World Wide Web and web servers. It then describes key features and functions of the Apache web server, including caching, logging, mapping URLs to files, access control, server-side includes, and virtual hosting.
The document discusses the history and fundamentals of interactive web technologies. It begins with HTTP and its limitations for pushing data from server to client. It then covers early techniques like meta refresh and AJAX polling. It discusses longer polling, HTTP chunked responses, and forever frames. It introduces Comet and web sockets as solutions providing true real-time bidirectional communication. It also covers server-sent events. In conclusion, it recommends using all these techniques together and frameworks like Socket.IO and SignalR that abstract the complexities and provide high-level APIs.
Deploy secure, scalable, and highly available web apps with Azure Front Door ...Stamo Petkov
The document summarizes a presentation about the Azure Front Door Service. The presentation discusses how the Front Door Service provides global load balancing and traffic management for web applications deployed to Azure. It enables deploying applications behind the Front Door to gain benefits like SSL offloading, caching, and failover across data centers. The presentation also covers how the Front Door Service integrates with features like the Azure Web Application Firewall for added security and protection against attacks. It concludes with a demo of the Front Door Service in action.
The document discusses web servers and their architecture. It begins by defining a web server as specialized software that responds to client requests from web browsers. It then describes the common three-tier architecture of web applications with tiers for the client interface, middle application logic, and database information. The document focuses on how web servers use HTTP to communicate with clients through a request-response protocol and provides examples of GET and POST requests. It also discusses leading web servers like Apache, IIS, and others as well as factors to consider when selecting a web server.
Web Technologies Notes - TutorialsDuniya.pdfRaghunathan52
This document provides an overview of web technologies including web servers, HTTP, HTML, URLs and the client-server model. It discusses popular web servers like Apache, IIS and XAMPP. It also explains the basic working of the internet using the client-server model, the world wide web, HTML, URLs, HTTP requests and responses. Key concepts around web browsers, servers, HTTP methods and status codes are defined.
Web Technologies Notes - TutorialsDuniya.pdfRaghunathan52
This document provides an overview of web technologies including the client-server model, web browsers, web servers, HTTP requests and responses, HTML, URLs, and the basic workings of the World Wide Web. It explains key concepts like how web browsers act as clients that make requests to web servers, which then return responses. It also covers the different components involved and standards like HTTP, HTML, and URLs that enable the functioning of the web.
Difference between Client Polling vs Server Push vs Websocket vs Long Pollingjeetendra mandal
Client polling, server push, websockets, and long polling are methods for real-time communication between clients and servers. Client polling involves the client regularly requesting updates from the server. Server push allows the server to proactively send updates to clients. With long polling, the server holds client requests until there is an update to send. Websockets provide full-duplex communication over a single TCP connection. Server push uses server-sent events to stream data from server to client without polling. Websockets enable bidirectional communication while server push only allows server to client. Both have advantages for different use cases depending on the need for bidirectional updates.
This document provides an overview of servlets and JSPs. It discusses how servlets were developed to address disadvantages of CGI programs. Servlets run within a web container and have a lifecycle of init(), service(), and destroy() methods. The document also covers implementing a simple servlet, using HttpServletRequest and HttpServletResponse objects, and configuring servlets in web.xml. It describes how JSPs work by being converted to servlets and discusses JSP directives, actions, and scripting elements.
The document discusses servlet technology and how it is used to create dynamic web applications. Some key points:
- Servlet technology allows creating web applications that reside on the server-side and generate dynamic web pages.
- Servlets are more robust and scalable than previous CGI technology due to being implemented in Java.
- The servlet API defines interfaces like Servlet, GenericServlet, HttpServlet, ServletRequest, and ServletResponse that are used to build servlets.
The Java Mail Server project allows clients to connect to a mail server to send and receive emails and attachments. The project is divided into three modules: a server module that uses server sockets to accept client connections, a client module that uses sockets to connect to the server, and an email inbox module that handles mail functions like forwarding, viewing attachments, and saving emails. The server stores details of client connections, mail sending and receiving. Clients can connect when the server is active to exchange emails with other clients. Usernames and passwords are stored in data files rather than a SQL server. The project provides automatic threading to handle socket connections and includes features for reliable TCP communication between clients.
Reverse Ajax, also known as Comet, allows a server to push data to a client without the client explicitly requesting it. This is achieved through techniques like long polling where the client opens a persistent connection to the server to receive messages as they happen. Common libraries that implement Reverse Ajax include CometD, Atmosphere, and DWR, with CometD being a preferred option as it supports websockets and offers full client/server functionality.
HTTP is a protocol used to access data on the World Wide Web. Tim Berners-Lee initially developed HTTP in 1989 while working at CERN. HTTP follows a client-server model where a client (usually a web browser) sends an HTTP request to a server, which then returns an HTTP response. The standard port for HTTP is 80. HTTP allows for the transfer of text, audio, video, and other data over the internet.
The document discusses stateless and stateful protocols. It provides HTTP and FTP as examples. A stateless protocol like HTTP does not store transaction information between requests, simplifying server design but requiring additional information in each request. Stateful protocols like FTP can remember transaction details like the identity of a client downloading files. The document also discusses how HTTP uses cookies and sessions to simulate state on stateless connections, allowing servers to recognize returning clients through the data stored in cookies.
MCIS 6163 Assignment 1/MCIS 6163 Assignment 1.pdf
Assignment 1 – MCIS 6163
Building a Simple Web Client and a Multithreaded Web Server
Objectives
To understand client-server communication via sockets.
To gain exposure to the basic operations of a Web server and client.
To explore basic structures of HTTP messages.
Due: April 14, 2020 11:59pm
Project Description
In this project, you will be developing a multithreaded Web server and a simple web client. The Web
server and Web client communicate using a text-based protocol called HTTP (Hypertext Transfer
Protocol).
Requirements for the Web server
The server is able to handle multiple requests concurrently. This means the implementation is
multithreaded. In the main thread, the server listens to a specified port, e.g., 8080. Upon receiving an
HTTP request, the server sets up a TCP connection to the requesting client and serves the request in a
separate thread. After sending the response back to the client, it closes the connection.
The server is assumed to work with HTTP GET messages. If the requested file exists, the server
responds with “HTTP/1.1 200 OK” together with the requested page to the client, otherwise it sends a
corresponding error message, e.g., “HTTP/1.1 404 Not Found” or “HTTP/1.1 400 Bad Request”.
If running the server program using command line, the syntax should be:
server_code_name [<port_number>]
where the optional <port_number> is the port on which the server is listening to connections from
clients. If the port number is not entered, the default port 8080 is used.
You can test your Web server implementation on your local machine using a Web browser, e.g.,
Internet Explorer, Firefox, or Chrome. You need to specify the used port number within the URL, for
example,
http://localhost:8080/index.htm
If omitting the port number portion, i.e., 8080, the browser will use the default port 80.
The server should response with a default page when users do not enter a specific page in the URL,
for example,
http://localhost:8080/
It should also work when the request includes a path to the requested file, for example,
http://localhost:8080/path/to/file/example.htm
You should display/log the request and header lines of request messages on the server for the purpose
of debugging.
Requirements for the simple Web client
The client is able to connect to the server via a socket and to request a page on the server.
Upon receipt of the response message from the server, the client extracts and displays/logs the
message status, and then retrieves the page content from the message body.
If running the client program using command line, the syntax should be:
client_code_name <server_IPaddress/name> [<port_number>] [<requested_file_name>]
where the <server_IPaddress/name> is the IP address or name of the Web server, e.g., 127.0.0.1 or
localhost for the server running on the local machine. The optional < ...
MCIS 6163 Assignment 1/MCIS 6163 Assignment 1.pdf
Assignment 1 – MCIS 6163
Building a Simple Web Client and a Multithreaded Web Server
Objectives
To understand client-server communication via sockets.
To gain exposure to the basic operations of a Web server and client.
To explore basic structures of HTTP messages.
Due: April 14, 2020 11:59pm
Project Description
In this project, you will be developing a multithreaded Web server and a simple web client. The Web
server and Web client communicate using a text-based protocol called HTTP (Hypertext Transfer
Protocol).
Requirements for the Web server
The server is able to handle multiple requests concurrently. This means the implementation is
multithreaded. In the main thread, the server listens to a specified port, e.g., 8080. Upon receiving an
HTTP request, the server sets up a TCP connection to the requesting client and serves the request in a
separate thread. After sending the response back to the client, it closes the connection.
The server is assumed to work with HTTP GET messages. If the requested file exists, the server
responds with “HTTP/1.1 200 OK” together with the requested page to the client, otherwise it sends a
corresponding error message, e.g., “HTTP/1.1 404 Not Found” or “HTTP/1.1 400 Bad Request”.
If running the server program using command line, the syntax should be:
server_code_name [<port_number>]
where the optional <port_number> is the port on which the server is listening to connections from
clients. If the port number is not entered, the default port 8080 is used.
You can test your Web server implementation on your local machine using a Web browser, e.g.,
Internet Explorer, Firefox, or Chrome. You need to specify the used port number within the URL, for
example,
http://localhost:8080/index.htm
If omitting the port number portion, i.e., 8080, the browser will use the default port 80.
The server should response with a default page when users do not enter a specific page in the URL,
for example,
http://localhost:8080/
It should also work when the request includes a path to the requested file, for example,
http://localhost:8080/path/to/file/example.htm
You should display/log the request and header lines of request messages on the server for the purpose
of debugging.
Requirements for the simple Web client
The client is able to connect to the server via a socket and to request a page on the server.
Upon receipt of the response message from the server, the client extracts and displays/logs the
message status, and then retrieves the page content from the message body.
If running the client program using command line, the syntax should be:
client_code_name <server_IPaddress/name> [<port_number>] [<requested_file_name>]
where the <server_IPaddress/name> is the IP address or name of the Web server, e.g., 127.0.0.1 or
localhost for the server running on the local machine. The optional <.
A web server is software that responds to requests from web browsers to serve web pages. It is part of a multi-tier architecture with an information tier (database), middle tier (application logic), and client tier (user interface). The most common protocol for communication between clients and servers is HTTP, with the server responding to GET and POST requests with web pages or other responses. Popular web server software includes Apache, IIS, and Tomcat.
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at ScaleC2B2 Consulting
JUDCon 2013 Presentation by Mark Addy, C2B2 Senior Consultant- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
The real time web is coming with WebSockets in HTML 5. The big question is how to deliver event driven architectures for WebSockets at scale. This session delivered by the experienced middleware consultant provides an insight on how combining JBoss Data Grid with WebSockets can deliver enterprise scale push to web devices. The session first provides an introduction to WebSockets and delves into typical JBoss Data Grid architectures and how they deliver linear scalability and high availability. We then look at the event capabilities inherent in JBoss Data Grid that when hooked up to a WebSockets server can deliver data grid updates in real time to HTML 5 mobile devices.
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...WebStackAcademy
Setting up a servlet environment
Servlets are Java programs that run on a Web server and build Web pages. Here are a few definitions:
Servlet Development Kits
Java Servlet Development Kit (JSDK) provides Servlet API classes (servlet.jar). Place servlet.jar into CLASSPATH, so that java classes can access it.
Servlet Engines
A servlet is a Java class that needs to be executed in a Java VM by servlet engine. The servlet engine loads the servlet class the first time the servlet is requested. The servlet then stays loaded to handle multiple requests until it is explicitly unloaded or the servlet engine is shut down.
Following are few WebServers that supports servlets:
Apache Tomcat
BEA WebLogic
IBM Websphere
Sun's Java Web Server (JWS)
Apache Tomcat.
Java Servlet Development Kit (JSDK)
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Zilliz
Join us to introduce Milvus Lite, a vector database that can run on notebooks and laptops, share the same API with Milvus, and integrate with every popular GenAI framework. This webinar is perfect for developers seeking easy-to-use, well-integrated vector databases for their GenAI apps.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
2. Introduction
• Currently working as a Senior Software Engineer
at Blue Jeans Network. Bluejeans.com
• Worked at Sun Microsystems/Oracle for 13 years
• Committer to numerous open source projects
including GlassFish
Copyright 2013, Bhakti Mehta all rights reserved
4. What you will learn
• Start thinking asynchronously
• Cover different technologies with respect to async
support
• Cover concepts from J2SE and J2EE with respect
to asynchronous processing
Copyright 2013, Bhakti Mehta all rights reserved
5. Why Think Async?
• Increase speed of processing through
parallelization
• Involve multiple CPU cores for processing than
single fast CPU
• Compare with older request response models and
see the benefits
Copyright 2013, Bhakti Mehta all rights reserved
6. Where async can be
used?
• Long running operations
• Processor intensive tasks
• Background tasks
• To improve application throughput
• To improve application response time
Copyright 2013, Bhakti Mehta all rights reserved
7. Usecases
• User John Doe wants to download multiple files
from different locations.
Solution
• Execute requests asynchronously and wait for
results from Future object
Copyright 2013, Bhakti Mehta all rights reserved
8. Usecases
• Use John Doe has a large data to post to a URL
Solution
Use callbacks instead of waiting and blocking for
response
Copyright 2013, Bhakti Mehta all rights reserved
9. Usecases
• Use John Doe want to upload a large file
Solution
Use AsynchronousFileChannel from JDK 7
Copyright 2013, Bhakti Mehta all rights reserved
10. Polling
• Polling
Used by vast majority of AJAX applications
Poll the server for data
Client --->request--> Server
If no data empty response is returned
Not a true asynchronous mechanism
Copyright 2013, Bhakti Mehta all rights reserved
11. Polling
Copyright 2013, Bhakti Mehta all rights reserved
Request (client_id)
Response 200 OK: empty
Request (client_id)
….
….
….
….
Response 200 OK: message
body
12. Polling Drawbacks
Http overhead
Reducing the interval will consume more
bandwidth and processing resources for nothing.
Copyright 2013, Bhakti Mehta all rights reserved
13. Long Polling
If server does not have data holds request open
COMET
Chunked transfer encoding can be used to send
chunks of data as part of response body which is
opened as a stream.
Chunks can be javascript tags loaded in hidden
iframe and executed in order of arrival
Copyright 2013, Bhakti Mehta all rights reserved
14. Long Polling
Copyright 2013, Bhakti Mehta all rights reserved
Request (client_id)
Response 200 OK: message
body
Request (client_id)
….
….
….
Response 200 OK: message
body
….
….
15. Long Polling Drawbacks
• No standard data format or message format when
used in chunked transfer encoding mode
• Each connection initiation has the initiation cost.
• No caching between clients and server, which
impacts the server performance instead of reading
some contents from the cache.
Copyright 2013, Bhakti Mehta all rights reserved
16. Server-sent Events
Unidirectional channel between server and client
Server pushes data to your app when it wants
asynchronously
Updates can be streamed from server to client as
they happen
Copyright 2013, Bhakti Mehta all rights reserved
18. WebSockets
Next generation of asynchronous communication
from client to server
Full duplex communication in either direction
After initial handshake on http communication is
over TCP socket using ws(unsecure) or
wss(secure) protocol
Copyright 2013, Bhakti Mehta all rights reserved
19. WebSocket Handshake
Client and Server upgrade from Http protocol to WebSocket protocol during initial handshake
GET /text HTTP/1.1rn
Upgrade: WebSocketrn
Connection: Upgradern
Host: www.websocket.orgrn …rn
Handshake from server looks like
HTTP/1.1 101 WebSocket Protocol Handshakern
Upgrade: WebSocketrn
Connection: Upgradern …rn
Copyright 2013, Bhakti Mehta all rights reserved
20. WebSockets
After the upgrade HTTP is completely out of the
picture at this point.
Using the lightweight WebSocket wire protocol,
messages can now be sent or received by either
endpoint at any time.
Creating a Websocket
ws = new WebSocket("ws://localhost:8080/../WebSocketChat");
You can set handlers for events onopen or onerror
Copyright 2013, Bhakti Mehta all rights reserved
22. Components ofAsyncServlet
• New attribute asyncSupported on @WebServlet annotation
or in web.xml
• AsyncContext
• Thread Pool
• Runnable instance
Copyright 2013, Bhakti Mehta all rights reserved
23. AsyncServlet
• When asyncSupported attribute is set to true
response is not committed on method exit
• Calling startAsync() method of AsyncContext
caches the request response pair
• The method returns and original thread is recycled
• AsyncListener and AsyncEvent give developers
control of the asynchronous lifecycle events
Copyright 2013, Bhakti Mehta all rights reserved
24. AsyncServlet
final AsyncContext asyncContext = request.startAsync();
asyncContext.setTimeout(600000);
asyncContext.addListener(new AsyncListener()
Implement the following method of the AsyncListener
onComplete(), onError(),OnTimeout(), onstartAsync()
Copyright 2013, Bhakti Mehta all rights reserved
25. Servlet 3.1:Non blocking IO
• ReadListener
• WriteListener
• These are then registered using
ServletInputStream.setReadListener and
ServletOutputStream.setWriteListener. The
listeners have callback methods that are invoked
when the content is available to be read or can be
written without blocking.
Copyright 2013, Bhakti Mehta all rights reserved
26. Servlet 3.1: Non blocking IO
public interface ReadListener extends EventListener {
public void onDataAvailable(ServletRequest request);
public void onAllDataRead(ServletRequest request);
public void onError(Throwable t);
}
Copyright 2013, Bhakti Mehta all rights reserved
27. Servlet 3.0: Non blocking IO
• The onDataAvailable: Invoked when all data for
the current request has been read.
• The onAllDataRead: Method is invoked by the
container the first time when it is possible to read
data.
• The onError: Invoked when an error occurs
processing the request
Copyright 2013, Bhakti Mehta all rights reserved
28. Servlet 3.0: Non blocking IO
public interface WriteListener extends EventListener {
public void onWritePossible(ServletResponse response);
public void onError(Throwable t);
}
Copyright 2013, Bhakti Mehta all rights reserved
29. Servlet 3.0: Non blocking IO
• The container invokes the onWritePossible
method when it is possible to write in the Servlet’s
OutputStream.
• The onError is invoked when writing in the
Servlet’s OutputStream encounters an exception.
Copyright 2013, Bhakti Mehta all rights reserved
30. ServletOutputStream
• In the ServletOutputStream interface
• isReady: This method can be used to determine
if data can be written without blocking.
• setWriteListener: Instructs the
ServletOutputStream to invoke the provided
WriteListener when it is possible to write
Copyright 2013, Bhakti Mehta all rights reserved
31. ServletInputStream
• In the ServletInputStream interface
• isFinished: Returns true when all the data from
the stream has been read else it returns false.
• isReady: Returns true if data can be read
without blocking else returns false.
• setReadListener: Instructs the
ServletInputStream to invoke the provided
ReadListener when it is possible to read
Copyright 2013, Bhakti Mehta all rights reserved
33. JAX-RS 2.0 Server
sideAsync support
• AsyncResponse: An injectable JAX-RS
asynchronous response that provides means for
asynchronous server side response processing.
• @Suspended: The @Suspended instructs the
container that the HTTP request processing should
happen in a secondary thread.
• CompletionCallback: A request processing callback
that receives request processing completion events.
Has onComplete() callback
• ConnectionCallback: Asynchronous request
processing lifecycle callback that receives
connection related asynchronous response lifecycle
events.
Copyright 2013, Bhakti Mehta all rights reserved
34. JAX-RS 2.0 Server
sideAsync support
• InvocationCallback: Callback that can be
implemented to receive the asynchronous
processing events from the invocation
processing.
• Future: Allows the client to poll for completion of
the asynchronous operation or to block and wait
for it.
Copyright 2013, Bhakti Mehta all rights reserved
38. EJB 3.1
• @Asynchronous annotation introduced in EJB 3.1
• Methods annotated with @Asynchronous will
return immediately regardless of how long the
method usually takes.
• Each invocation returns a Future object which is
initially empty and will have its value filled later
when method completes
Copyright 2013, Bhakti Mehta all rights reserved
39. AsyncResult
• AsyncResult<V> wraps the result of an
asynchronous method call as a Future object
• The value specified in the constructor
AsyncResult(V result) will be retrieved by
Container and sent to client.
Copyright 2013, Bhakti Mehta all rights reserved
40. Cancelling an async
invocation
• The session bean can check whether the client
requested that the invocation be cancelled by
calling
the javax.ejb.SessionContext.wasCancelled().
Copyright 2013, Bhakti Mehta all rights reserved
41. @Asynchronous code
snippet@Path(“/books/borrow”)
@Stateless
public class BookResource {
@Context private ExecutionContext ctx;
@GET @Produce(“application/json”)
@Asynchronous
public void borrow() {
Executors.newSingleThreadExecutor().submit( new Runnable() {
public void run() {
Thread.sleep(10000);
ctx.resume(“Hello async world!”);
} });
ctx.suspend();
return; }} Copyright 2013, Bhakti Mehta all rights reserved
42. Java SE and Think Async
• Future
• A Future object represents the result of
asynchronous completion.
• Methods to check if computation is complete, wait
for result and retrieve results.
• Cancellation can be performed by cancel method
Copyright 2013, Bhakti Mehta all rights reserved
44. AsynchronousFileChannel
try (AsynchronousFileChannel asyncChannel = AsynchronousFileChannel.open(path)){
//Returns a Future instance which can be used to read the contents of the
file.
Future<Integer> fileResult = asyncChannel.read(buffer, 0);
while(!fileResult.isDone()){
System.out.println("Waiting to complete the file reading ...");
}
Copyright 2013, Bhakti Mehta all rights reserved
45. Call for action
• Download GlassFish 4.0 from
glassfish.dev.java.net for latest JavaEE7 API
• File issues, contribute patches
• Email users@glassfish.dev.java.net
Copyright 2013, Bhakti Mehta all rights reserved
46. Questions
• Twitter: @bhakti_mehta
• Blog https://www.java.net//blogs/bhaktimehta
• LinkedIn: http://www.linkedin.com/in/bhaktihmehta
• Slideshttp://www.slideshare.net/bhaktiks/think-async
Copyright 2013, Bhakti Mehta all rights reserved
Editor's Notes
Long running operations—long running commandsProcessor intensive tasks –tasks that require a lot of computationBackgground tasks which can be batched and doneImprove application throughput by proc
When the asyncSupported attribute is set to true, the response object is not committed on method exit. Calling startAsync() returns an AsyncContext object that caches the request/response object pair. The AsyncContext object is then stored in an application-scoped queue. Without any delay, the doGet() method returns, and the original request thread is recycled. In the ServletContextListener object, separate threads initiated during application launch monitor the queue and resume request processing whenever the resources become available. After a request is processed, you have the option of calling ServletResponse.getWriter().print(...), and then complete() to commit the response, or calling forward() to direct the flow to a JSP page to be displayed as the result. Note that JSP pages are servlets with an asyncSupported attribute that defaults to false.In addition, the AsyncEvent and AsynListener classes in Servlet 3.0 give developers elaborate control of asynchronous lifecycle events. You can register an AsynListener through the ServletRequest.addAsyncListener() method. After the startAsync() method is called on the request, an AsyncEvent is sent to the registered AsyncListener as soon as the asynchronous operation has completed or timed out. The AsyncEvent also contains the same request and response objects as in the AsyncContext object.
After a listener is registered withServletOutStream the status of a nonblocking read can be checked by isReady() method
After a listener is registered withServletinputStream the status of a nonblocking read can be checked by isReady() method
Session beans can implement asynchronous methods, business methods where control is returned to the client by the enterprise bean container before the method is invoked on the session bean instance. Clients may then use the Java SE concurrency API to retrieve the result, cancel the invocation, and check for exceptions. Asynchronous methods are typically used for long-running operations, for processor-intensive tasks, for background tasks, to increase application throughput, or to improve application response time if the method invocation result isn’t required immediately.When a session bean client invokes a typical non-asynchronous business method, control is not returned to the client until the method has completed. Clients calling asynchronous methods, however, immediately have control returned to them by the enterprise bean container. This allows the client to perform other tasks while the method invocation completes. If the method returns a result, the result is an implementation of the java.util.concurrent.Future<V> interface, where “V” is the result value type. The Future<V>interface defines methods the client may use to check whether the computation is completed, wait for the invocation to complete, retrieve the final result, and cancel the invocation.Every time a method annotated @Asynchronous is invoked by anyone it will immediately return regardless of how long the method actually takes. Each invocation returns a Future object that essentially starts out empty and will later have its value filled in by the container when the related method call actually completes. Returning a Future object is not required and @Asynchronous methods can of course return void.
. Note that this object is not passed to the client. It is merely a convenience for providing the result value to the container. Therefore, none of its instance methods should be called by the application.
.
A Future represents the result of an asynchronous computation. Methods are provided to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation. The result can only be retrieved using method get when the computation has completed, blocking if necessary until it is ready. Cancellation is performed by the cancel method. Additional methods are provided to determine if the task completed normally or was cancelled. Once a computation has completed, the computation cannot be cancelled.