The Codex of Business Writing Software for Real-World Solutions 2.pptx
Â
Don't call us - we'll push - on cross tier push architecture (NLJUG JFall 2011, The Netherlands)
1. Lucas Jellema â AMIS (Nieuwegein)
DON'T CALL US - WE'LL PUSH â
ON CROSS TIER PUSH ARCHITECTURE
JavaOne 2011, Birds of a Feather
2. OVERVIEW
⢠Asynchronous to the max
⢠Push in enterprise architecture
⢠The harsh reality of push
⢠Web-tier to client
â Browser
â Mobile App
⢠Client to client
⢠Database tier to Business tier
⢠Cross Server Push
⢠Push All the way
⢠The future of push
â Real time
3. ASYNCHRONOUS COMMUNICATION
IN THE REAL WORLD
⢠âIâll get back to youâ
⢠âDonât call us,âŚâ
⢠Low fuel warning in car
⢠âPlease let me knowâ
⢠âReturn to sender â address unknownâ
⢠Newspaper delivery
⢠Next instruction from car navigation system
⢠Telephone ringing
⢠Alarm clock buzzing
⢠Parking sensors beeping
⢠Fire alarm screaming
4. ASYNCHRONOUS INTERACTIONS AND PUSH
IN THE IT LANDSCAPE
⢠More timely information
â Notification as soon as possible
⢠Proactive offering
â Do not ask and you shall be given
⢠Lower load on back end â donât call us (all the time) âŚ
â Stop hitting the F5 button!
⢠Multi-channel information manipulation and
dissemination
â Changes and events come in from everywhere
⢠Decouple system components through generic
infrastructure for handling events and push
â Yet integrate
5. PUSHING IT ⌠INTO THE USER INTERFACE
⢠Automatically refreshing (part of) a page
â Update table
â Redrawing chart
⢠Displaying popup to alert user to an event
â Arrival of message (email or chat)
â Signing in or out of contact (presence)
â Lock or release of some resource
â Notification
⢠Changing status of items on the page
â Highlight change indicator
â Show icon
â Change text to italic
⢠Play a sound
6. Mobile Mobile
Device Device
Web Browser Web Browser
Non
Complex Event JEE Application JEE Application
Java
Processor Server Server
Server
Email
RDBMS Chat Server
RDBMS Server
7. UPSTREAM NOTIFICATION
⢠Database to Middle Tier
⢠Middle Tier to Browser Mobile Device
or Mobile device
⢠Browser to other Web Browser
Browser or Mobile device
JEE Application Server
RDBMS
11. SERVER PUSH CHALLENGES
⢠How to push against the âone way directionâ and
despite limitations
â HTTP and JDBC are request/response â not response
only
â Browser limit of only two channels to one server
⢠Server side âevent handlingâ
â Session has to have an active life beyond requests
⢠Or requests have a life beyond response
â Higher load on the server
â How to handle the (potential) volume of âconcurrentâ
channels and the number of open threads
⢠NIO, Servlet 3.0, Jetty Continuations, Tomcat Advanced
I/O
12. SERVER PUSH CHALLENGES (2)
⢠Where do events to push actually come from?
â Who perceives/receives (real-time) events (on the
server side)
â How are they tied in to the appropriate sessions?
⢠Client (consumer) side: how to asynchronously
receive events and how to process them/turn them
into action and UI updates
⢠How to correlate an asynchronously received message
with a previously sent request or a subscription
â For example: mobile phone showing SMS or
WhatsApp messages in a conversation thread style
13. SERVER TO WEB CLIENT
⢠AJAX â Asynchronous
â Not as asynchronous as you might think
⢠Reverse AJAX â Comet , Push
â Comet implementations
⢠Streaming â never ending response
⢠Poll
⢠Long Poll
⢠Piggy Back (add push message to normal response)
⢠Embedded Applet doing raw TCP communications
â Flash with BlazeDS event streaming
⢠WebSockets
14. COMET â IMPLEMENTATIONS
⢠Client side:
â many libraries â DOJO is most notable
⢠most are AJAX/JavaScript based
⢠Applets could also be used (via Applet/JS bridge)
⢠Server Side:
â plain servlets,
â Servlet 3.0 to alleviate the load on the server from all
the open long-lived requests âŚ
â Grizzly (GlassFish)
â WebLogic HTTP Channel
â DWR â Direct Web Remoting
â LightStreamer
â Jetty
â Zie: http://cometdaily.com/maturity.html
15. DIRECT WEB REMOTING
⢠Call client side JavaScript functions from Server
â In multiple browser sessions
â Synchronously as part of request handling
â Asynchronously â as server (initiated) push
⢠Call server side Java methods from the Client
â Leading to asynchronous (âbackgroundâ) AJAX calls
16. SERVER PUSH WITH DWR
⢠DWR configuration:
â Servlet in web.xml
â WEB-INF/dwr.xml with beans to expose to JavaScript
Web Browser HTML +
JavaScript
JEE Application Server
Clock
17. CLIENT TO SERVER PUSH TO CLIENT
HTML + Web Browser Web Browser HTML +
JavaScript JavaScript
Servlet
JEE Application Server
Events
Processor
SomeTableWithEvents SomeTableWithEvents
Coordinator Coordinator
19. SPIN OFF ANOTHER THREAD TO DO THE
WORK AND INFORM ON PROGRESS
Web Browser
HTML +
JavaScript
Servlet
ServerSide DWR Bean
Perform long running
job & report progress
21. THE NUDGE
⢠Event should have small payload â just an indication
of the type of event and a key-reference to the payload
⢠Based on the information, the consumer decides to
retrieve the associated payload, using the key
nudge handler UI Component
Payload
Nudgee Retriever
Nudger
22. CLIENT TO CLIENT
⢠Usually really a combination of
â Client-to-Server
â and Server-to-the-other-Client push
⢠Exception: Blue Tooth, Near-Field Communication
Mobile Mobile
Device Device
Web Browser Web Browser
JEE Application
Server
24. APPLE PUSH NOTIFICATION SERVICE
⢠Persistent TCP/IP connection
â Continuously streaming
⢠TCP/IP connection is initially set up by client
â Passing its identifier to APNS
⢠Server side of applications can send messages to
APNS with the device identifier
⢠APNS streams these messages to the device
â Message payload is JSON
25. APPLE PUSH NOTIFICATION SERVICE
⢠Using APNS, only one channel is used for all
messages to be pushed to a device
â Shared by many different applications
⢠APNS does store-and-forward (to retain messages
when the client is off-line)
⢠Note: the push payload is very small (< 256 bytes)
â just enough for the client to initiate a request for the
real information
27. WEB SOCKETS
⢠Protocol â TCP based, initiated with normal HTTP
exchange
â One more transport option for Comet
â Finalized last month
⢠Client and Server API
â JavaScript (client)
â Server side?
⢠Part of HTML 5
â A very loose collection of proposals, concepts and
specifications
⢠Supported in Chrome and Safari as well as Firefox, âŚ
â Also from mobile platform
⢠Server Side Support very fragmented at this point
â With the protocol finalized, server support will rapidly
emerge
28. CROSS GAP PUSH MECHANISMS
⢠Many channels are available to push messages from
one entity to another
â across application, technology and location boundaries
⢠JMS (Java/JEE specific)
⢠(one way) WebService (SOAP or REST)
⢠âHTTP Channelâ
⢠WebSockets
⢠Http Call to Servlet
⢠XMPP
29. JMS (JAVA MESSAGE SERVICE) ==
THE âINTER APPLICATION MAIL MANâ
⢠JMS is perfect for highly decoupled, scalable, cross
JVM/cross server, reliable event push
⢠JMS is available on any JEE platform
⢠JMS is Java only
â Mobile devices, browsers, databases and .NET do not
speak JMS
Application A Application B
JMS
Queue
Application C Application X
30. JMS QUEUE/TOPIC LISTENER
⢠JMS Listener is notified asynchronously of messages
⢠Start background job on behalf of web app
â Note: spawn thread from Servlet or EJB is not
recommended
â Create report, send email, execute batch job
Web JMS Queue or
Topic MDB
Application
⢠Listen to events on behalf of web application
â And inform web application of relevant stuff
JMS Queue or ? Web
Topic MDB
Application
EJB
41. MULTIPLEXED POLL-BASED
DATABASE-TO-MIDDLE TIER PUSH
⢠A poll based approach can emulate the push behavior
â One thread in the middle tier does polling on behalf
of all sessions: a single channel
â A single table in
the database is Application Scope
used to collect event handler session
all âpushable session
Scheduled
eventsâ session
Job
â Middle tier poll
retrieves new
entries from the
table and published CD_TBL
events to central
event handler
Notificat
â Listeners registered ions Proce
-dure
with a central
event handler
42. FUTURE DEVELOPMENTS
⢠The real time enterprise
⢠The event driven enterprise
⢠Further evolution of push notification at every tier
â Mobile perhaps leading the way
⢠Infrastructure and frameworks providing push
mechanisms
⢠Servlet 3.0, Java NIO, WebSockets,
SPDY, XMPP and other lighter
weight solutions for bi-directional
communication over TCP
â And broad support in browsers
and application servers
â For example: upcoming
WebSockets support
in Glassfish and WebLogic
â Project Avatar
43. SUMMARY
⢠Asynchronous interaction is good for decoupling,
decreasing load on system and increasing timeliness
⢠Push is valuable at various levels and between
different components in the enterprise architecture
⢠Challenges:
â push is often against the [http, JDBC,..] grain
â correlate push notifications into right consumer
â handle asynchronously received push messages
â prevent swamping of infrastructure
⢠Server to client push will gain in scalability and ease
â Thanks to WebSockets and implementations thereof
and libraries (e.g. Dojo) leveraging it
â Also used for server-to-server and client-to-client
⢠Push is an essential ingredient of modern applications
â from browser and mobile to middle tier and database
Notas do Editor
Pushing information is a decoupled and performance effective way to ensure interested parties have the most recent information ASAP.This session looks at reasons and technology for pushing information at various points in an enterprise architecture. Databases can push to the middle tier - as a result of DML - the middle tier pushes to the browser - triggered by email, chat, JMS message or CEP event and one client can push to another. The link with Event Driven Architecture is explored.HTTP Channels and Web Sockets are demonstrated as well as AJAX based background push, database query result change notification and HTTP calls from the database. We'll look at what to send in an event and how to present  the push signal in the end.  * Introduce push in the real world: don't call us and other examples* Explain how push is good for performance (no polling), for decoupling (consumer does not need to know where the push comes from) and most up-to-date information available (as opposed to polling)* Discuss architecture and all the gaps between and within tier where push may be required and how the trigger can originate* Demonstrate how push can be implemented from a database to the middle tier (for example to refresh cache or send signal that ends up in client)* Demonstrate how push can be implemented from middle tier to client - and what it can be used for* Discussion of presentation/visualization of asynchronous, push-based refresh of client* Leveraging the server-client push, demonstrate how client-client push can be implemented (through client-server AJAX and server-client push)* Demonstrate end-to-end push: database undergoing some DML finally resulting in a browser being refreshed* Linking Push with Event Driven Architecture and Complex Event Processing* Brief future outlook* Summary
AsYnchronous communication & cross tier push in enterprise landscape
Two participantsOne can ask questionsThe other can reply; a response is ended with âend of messageâ; after that has been said, the responder has to wait for the next question to be asked before saying anything out loudChallenge: the requestor needs to know as fast as possible and with as few questions asked as possible when the responder is tapped on the back