ajax push (a.k.a comet) with java business integration
TRANSCRIPT
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
1/26
2007 JavaOneSM Conference | Session TS-8434 |
TS-8434
Ajax Push (a.k.a. Comet) WithJava Business Integration
(JBI)Andreas Egloff
Chief Architect for Open ESBSun Microsystems, Inc.http://open-esb.org
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
2/26
2007 JavaOneSM Conference | Session TS-8434 | 2
Goal of This Talk
Learn how to push your critical business
information out to Ajax clientswith lowerlatency and without compromisingscalability or performance
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
3/26
2007 JavaOneSM Conference | Session TS-8434 | 3
Agenda
Basics of Ajax PushArchitecture challenges
Technology solutions
How does JBI fit into the picture?
Demo
Potential drawbacks and pitfalls
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
4/26
2007 JavaOneSM Conference | Session TS-8434 | 4
Agenda
Basics of Ajax PushArchitecture challenges
Technology solutions
How does JBI fit into the picture?
Demo
Potential drawbacks and pitfalls
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
5/26
2007 JavaOneSM Conference | Session TS-8434 | 5
What Is Ajax Push Good For?
Use it to create highly responsive, event-driven applicationsin a browser Keep clients up-to-date with data arriving or changing on the server,
without frequent polling
Pros Lower latency, not dependent on polling frequency
Server and network do not have to deal with frequent pollingrequests to check for updates
Example applications Gmail and Google Talk
Meebo
JotLive
KnowNow
Many more
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
6/262007 JavaOneSM Conference | Session TS-8434 | 6
How Does Push to theBrowser Work?
Deliver data over a previously opened connection Always keep a connection open; do not respond tothe initiating request until event occurred
Streaming is an option by sending response in multipleparts and not closing the connection in between
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
7/262007 JavaOneSM Conference | Session TS-8434 | 7
Standard Ajax compared to Ajax Push options
How Does Push to theBrowser Work?
Browser Server
Ajax (Polling)
request
response
request
response
event
Server
Ajax Push (Long Poll)
request
response
request
Browser Server
Ajax Push (Streaming)
request
response part
Browser
response part
event event
event
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
8/262007 JavaOneSM Conference | Session TS-8434 | 8
Agenda
Basics of Ajax PushArchitecture challenges
Technology solutions
How does JBI fit into the picture?
Demo
Potential drawbacks and pitfalls
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
9/262007 JavaOneSM Conference | Session TS-8434 | 9
Architecture Challenges
Using blocking, synchronous technology willresult in a blocked thread for each openconnection that is waiting Every blocked thread will consume memory
This lowers scalability and can affect performance
To get the Java Virtual Machine (JVM) to scale to10,000 threads and up needs specific tuning and is not
an efficient way of solving this
Servlets 2.5 are an example of blocking,synchronous technology
The terms Java Virtual Machine and JVM mean a Virtual Machine for the Java platform.
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
10/262007 JavaOneSM Conference | Session TS-8434 | 10
Affect of blocking threads (default thread stack size)
Architecture Challenges
Stack Memory Requirements
0
5
10
15
20
1000
3000
5000
7000
9000
11,000
13,000
15,000
17,000
19,000
Number of Threads
Gigabytes
64-bit 1.6 JVM
Machine
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
11/262007 JavaOneSM Conference | Session TS-8434 | 11
Agenda
Basics of Ajax PushArchitecture challenges
Technology solutions
How does JBI fit into the picture?
Demo
Potential drawbacks and pitfalls
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
12/262007 JavaOneSM Conference | Session TS-8434 | 12
Technology Solutions
Use new I/O (NIO) non-blocking sockets to avoid blockinga thread per connection
Use technology that supports asynchronous requestprocessing
Release the original request thread while waiting for an event
May process the event/response on another thread than theoriginal request
Advantages Number of clients is primarily limited by the number of open
sockets a platform can support
Could have all clients (e.g., 10,000) waiting without any threads
processing or blocked
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
13/262007 JavaOneSM Conference | Session TS-8434 | 13
Agenda
Basics of Ajax PushArchitecture challenges
Technology solutions
How does JBI fit into the picture?
Demo
Potential drawbacks and pitfalls
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
14/262007 JavaOneSM Conference | Session TS-8434 | 14
How Does Java Business
Integration (JBI) Fit Into thePicture?
The JBI 1.0 (JSR 208) framework provides thebasis for building loosely coupled compositeapplications by combining services
JBI is inherently asynchronous Components exchange requests and responsesthrough in-memory queues (the normalizedmessage router)
Complements the asynchronous nature of Ajax Push
JSR = Java Specification Request
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
15/262007 JavaOneSM Conference | Session TS-8434 | 15
Why Should I Care About JBI?
JBI provides a standard to plug in server-side containers for business
logic and transformations, e.g.: XSLT engine
BPEL engine
JavaScript engine
YASU rules engine
Many more
Choose the best-of-breed containers from the provider(s) you like
Because JBI components are interoperable you can chain, mix, andmatch the right technologies to solve your business problems
External connectivity (binding components) is separate from thebusiness logic containers (service engines); hence every container
has access to all the pluggable external connectivity capabilities
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
16/262007 JavaOneSM Conference | Session TS-8434 | 16
JBI Key Components
Service Engines (SE)pluggable business logic containers
Binding Components (BC)pluggable external connectivity
Normalized message router (NMR)standard way of exchangingmessages between components
Normalized Message Router (NMR)
JMS BC FTP BC HL7 BC Many more BCs
Java EE SE XSLT SE BPEL SE IEP SE Many more SEs
HTTP BC
Java EE = Java Platform, Enterprise Edition | Java SE = Java Platform, Standard Edition | JMS = Java Message Service
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
17/262007 JavaOneSM Conference | Session TS-8434 | 17
HTTP Connector in JBI
The Java EE platform 5 SDK includes a JBI implementation;
a sub-set of the open source Project Open Enterprise ServiceBus (Open ESB)
Open ESB includes a fully featured HTTP bindingcomponent (BC) Built on the Grizzly high-performance NIO framework
and uses non-blocking sockets
Grizzly supports asynchronous request processing anddoes not block threads
Grizzly even supports non-blocking sockets when usingSSL to secure the connection
Leverages a re-architected Java API for XML Web Services (JAX-WS)stack that supports separate threads to process the request and response
This ensures that the HTTP BC takes full advantage of theasynchronous nature of JBI
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
18/262007 JavaOneSM Conference | Session TS-8434 | 18
Considerations for ServiceEngines
To handle the wait for an event in Ajax Push,choose a container/language that does not haveto block
Some inherently do not block e.g., BPEL receive activity can wait for eventswithout blocking a thread
Continuations are another options e.g., JavaScript technology continuation in the
Rhino open source implementation
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
19/262007 JavaOneSM Conference | Session TS-8434 19
DEMOAjax Push With JBI
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
20/262007 JavaOneSM Conference | Session TS-8434 | 20
Agenda
Basics of Ajax PushArchitecture challenges
Technology solutions
How does JBI fit into the picture?
Demo
Potential drawbacks and pitfalls
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
21/262007 JavaOneSM Conference | Session TS-8434 | 21
Potential Drawbacks and Pitfalls
Beware of flooding clients with too many events
Firewalls may terminate connections after a certainamount of time
Solution: re-establish connection after tear-down or at
certain intervals
The HTTP 1.1 specification suggests a limit of twosimultaneous connections from a client to the same host
Some use a separate host name for the Push connection In security terms the attack surface is very similar to
standard Ajax applications, for denial of service (DoS)the wait is a consideration
Simple Long Poll Ajax Push is portable across browsers
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
22/26
2007 JavaOneSM Conference | Session TS-8434 | 22
Potential Drawbacks and PitfallsWith Streaming
Streaming is more challenging Portability issue to different browsers and
XMLHttpRequest (XHR)
IE, for example, does not make data available until
connection close
Some solutions use IFrames instead for portability
With streaming data will accumulate, release
memory regularly Primitive proxies may buffer data in a way that
interferes with streaming
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
23/26
2007 JavaOneSM Conference | Session TS-8434 | 23
Summary
Pushing data to the web client can form a crucialtool in the developers arsenal when latency isimportant
Long-Poll is straight forward and portable Streaming today is more complex and has
portability implications
JBI complements the asynchronous nature ofAjax Push and gives the user the freedom to mixand match the right server side tools to solve their
business problems
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
24/26
2007 JavaOneSM Conference | Session TS-8434 | 24
For More Information
Cross-references to other sessions TS-8897: Designing Service Collaborations:
The Design of Wire-Centric Integration
TS-8683: Introduction to CASA: An Open Source
Composite Applications Editor
Links Open ESB community
http://open-esb.org
Grizzly NIO frameworkhttp://grizzly.dev.java.net
Andis Bloghttp://blogs.sun.com/andi
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
25/26
2007 JavaOneSM Conference | Session TS-8434 25
Q&AAndreas Egloff
-
8/10/2019 Ajax Push (a.k.a Comet) With Java Business Integration
26/26
TS-8434
Ajax Push (a.k.a. Comet) WithJava Business Integration
(JBI)Andreas Egloff
Product Line Architect for AlaskaSun Microsystems, Inc.http://open-esb.org