Your SlideShare is downloading. ×
0
Lucas Jellema – AMIS (Nieuwegein)DONT CALL US - WELL PUSH –ON CROSS TIER PUSH ARCHITECTUREJavaOne 2011, Birds of a Feather
OVERVIEW•   Asynchronous to the max•   Push in enterprise architecture•   The harsh reality of push•   Web-tier to client ...
ASYNCHRONOUS COMMUNICATIONIN THE REAL WORLD•   “I‟ll get back to you”•   “Don‟t call us,…”•   Low fuel warning in car•   “...
ASYNCHRONOUS INTERACTIONS AND PUSHIN THE IT LANDSCAPE• More timely information   – Notification as soon as possible• Proac...
PUSHING IT … INTO THE USER INTERFACE• Automatically refreshing (part of) a page   – Update table   – Redrawing chart• Disp...
Mobile        Mobile                                   Device        DeviceWeb Browser       Web Browser                  ...
UPSTREAM NOTIFICATION• Database to Middle Tier• Middle Tier to Browser                Mobile Device  or Mobile device• Bro...
TYPICAL SERVER-TO-CLIENT PUSHSCENARIO: CHAT                      Web Browser                   JEE Application Server
AND CLIENT TO SERVER (TO SERVER)                       Web Browser                    JEE Application Server
THE „ONLY TELL WHEN ASKED‟ GAME
SERVER PUSH CHALLENGES• How to push against the „one way direction‟ and  despite limitations   – HTTP and JDBC are request...
SERVER PUSH CHALLENGES (2)• Where do events to push actually come from?   – Who perceives/receives (real-time) events (on ...
SERVER TO WEB CLIENT• AJAX – Asynchronous   – Not as asynchronous as you might think• Reverse AJAX – Comet , Push   – Come...
COMET – IMPLEMENTATIONS• Client side:   – many libraries – DOJO is most notable        • most are AJAX/JavaScript based   ...
DIRECT WEB REMOTING• Call client side JavaScript functions from Server   – In multiple browser sessions   – Synchronously ...
SERVER PUSH WITH DWR• DWR configuration:   – Servlet in web.xml   – WEB-INF/dwr.xml with beans to expose to JavaScript    ...
CLIENT TO SERVER PUSH TO CLIENT HTML +      Web Browser                            Web Browser    HTML +JavaScript        ...
ASYNCHRONOUS JOBPROGRESS INDICATOR
SPIN OFF ANOTHER THREAD TO DO THE     WORK AND INFORM ON PROGRESS             Web Browser HTML +JavaScript                ...
DEMO
THE NUDGE• Event should have small payload – just an indication  of the type of event and a key-reference to the payload• ...
CLIENT TO CLIENT •   Usually really a combination of      – Client-to-Server      – and Server-to-the-other-Client push • ...
SERVER TO MOBILE PUSH:MULTIPLEXED, SEMI-POLL BASED
APPLE PUSH NOTIFICATION SERVICE• Persistent TCP/IP connection   – Continuously streaming• TCP/IP connection is initially s...
APPLE PUSH NOTIFICATION SERVICE• Using APNS, only one channel is used for all  messages to be pushed to a device   – Share...
ANDROID PUSH NOTIFICATIONMULTIPLEXED FROM THE CLOUD
WEB SOCKETS• Protocol – TCP based, initiated with normal HTTP  exchange   – One more transport option for Comet   – Finali...
CROSS GAP PUSH MECHANISMS• Many channels are available to push messages from  one entity to another   – across application...
JMS (JAVA MESSAGE SERVICE) ==     THE “INTER APPLICATION MAIL MAN”     • JMS is perfect for highly decoupled, scalable, cr...
JMS QUEUE/TOPIC LISTENER   • JMS Listener is notified asynchronously of messages   • Start background job on behalf of web...
LIVE VOLLEYBALL REPORTING                         Web Browser       JMS Queue                                  UI handler ...
CROSS TIER PUSH –ARCHITECTURE PATTERN    listener        listener       listener  register                   event handler...
THE HOLLYWOOD PRINCIPLE:QUERY RESULTSET CHANGE NOTIFICATION
MIDDLE TIER ALERTED BY DATABASESQL query
REGISTER DATABASE CHANGELISTENER
QUERY RESULT CHANGE LISTENER
UPDATE IN DATABASETRIGGERS NOTIFICATION TO JAVALISTENER
MULTIPLEXED POLL-BASEDDATABASE-TO-MIDDLE TIER PUSH• When no Database Query Result Change Notification  is available – a tr...
DATABASE TO MIDDLE TIER TO CLIENTNOTIFICATION           Session          Application Scope            cache            eve...
DEMO CROSS TIER PUSH – DATABASE MIDDLE TIER  BROWSER
MULTIPLEXED POLL-BASEDDATABASE-TO-MIDDLE TIER PUSH• A poll based approach can emulate the push behavior   – One thread in ...
FUTURE DEVELOPMENTS• The real time enterprise• The event driven enterprise• Further evolution of push notification at ever...
SUMMARY• Asynchronous interaction is good for decoupling,  decreasing load on system and increasing timeliness• Push is va...
Don't call us - we'll push - on cross tier push architecture (NLJUG JFall 2011, The Netherlands)
Upcoming SlideShare
Loading in...5
×

Don't call us - we'll push - on cross tier push architecture (NLJUG JFall 2011, The Netherlands)

979

Published on

.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
979
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • 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
  • http://127.0.0.1:7101/DWRPushBasic/eventprocessor?payload=dododohttp://127.0.0.1:7101/DWRPushBasic/EventsTableDemo.html
  • http://technology.amis.nl/blog/13823/adf-faces-handle-task-in-background-process-and-show-real-time-progress-indicator-for-asynchronous-job-using-server-push-in-adf
  • http://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/RemoteNotificationsPG.pdf
  • Transcript of "Don't call us - we'll push - on cross tier push architecture (NLJUG JFall 2011, The Netherlands)"

    1. 1. Lucas Jellema – AMIS (Nieuwegein)DONT CALL US - WELL PUSH –ON CROSS TIER PUSH ARCHITECTUREJavaOne 2011, Birds of a Feather
    2. 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. 3. ASYNCHRONOUS COMMUNICATIONIN 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. 4. ASYNCHRONOUS INTERACTIONS AND PUSHIN 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. 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. 6. Mobile Mobile Device DeviceWeb Browser Web Browser Non Complex Event JEE Application JEE Application Java Processor Server Server Server Email RDBMS Chat Server RDBMS Server
    7. 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
    8. 8. TYPICAL SERVER-TO-CLIENT PUSHSCENARIO: CHAT Web Browser JEE Application Server
    9. 9. AND CLIENT TO SERVER (TO SERVER) Web Browser JEE Application Server
    10. 10. THE „ONLY TELL WHEN ASKED‟ GAME
    11. 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. 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. 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. 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. 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. 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. 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
    18. 18. ASYNCHRONOUS JOBPROGRESS INDICATOR
    19. 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
    20. 20. DEMO
    21. 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. 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 DeviceWeb Browser Web Browser JEE Application Server
    23. 23. SERVER TO MOBILE PUSH:MULTIPLEXED, SEMI-POLL BASED
    24. 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. 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
    26. 26. ANDROID PUSH NOTIFICATIONMULTIPLEXED FROM THE CLOUD
    27. 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. 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. 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 JMSApplication A Application B JMS QueueApplication C Application X
    30. 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 stuffJMS Queue or ? Web Topic MDB Application EJB
    31. 31. LIVE VOLLEYBALL REPORTING Web Browser JMS Queue UI handler Listener (http channel, JMS, ..)
    32. 32. CROSS TIER PUSH –ARCHITECTURE PATTERN listener listener listener register event handler Scheduled Payload Push Poll Job Retriever Receptor ‘Events collector’
    33. 33. THE HOLLYWOOD PRINCIPLE:QUERY RESULTSET CHANGE NOTIFICATION
    34. 34. MIDDLE TIER ALERTED BY DATABASESQL query
    35. 35. REGISTER DATABASE CHANGELISTENER
    36. 36. QUERY RESULT CHANGE LISTENER
    37. 37. UPDATE IN DATABASETRIGGERS NOTIFICATION TO JAVALISTENER
    38. 38. MULTIPLEXED POLL-BASEDDATABASE-TO-MIDDLE TIER PUSH• When no Database Query Result Change Notification is available – a trick is needed• Some databases can do HTTP calls:
    39. 39. DATABASE TO MIDDLE TIER TO CLIENTNOTIFICATION Session Application Scope cache event handler D 5 3 C 4 9 A 1 servlet servlet 2 8 B HTTP Proce 7 -dure EMP 6 Job
    40. 40. DEMO CROSS TIER PUSH – DATABASE MIDDLE TIER  BROWSER
    41. 41. MULTIPLEXED POLL-BASEDDATABASE-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. 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. 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
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×