Slide 1 What the Bayeux? Filip Hanik SpringSource Inc Keystone, Colorado, 2008.

Slides:



Advertisements
Similar presentations
WEB SERVICES. FIRST AND FOREMOST - LINKS Tomcat AXIS2 -
Advertisements

JSON Valery Ivanov.
ASP.Net, web services--- asynchronous and synchronous and AJAX By Thakur Rashmi Singh.
Interprocess Communications
1 Cleaning up the Internet Using AJAX, SOAP and Comet CS526 Mike Gerschefske Justin Gray James Yoo 02 May 2006.
Cloud Computing Lecture #7 Introduction to Ajax Jimmy Lin The iSchool University of Maryland Wednesday, October 15, 2008 This work is licensed under a.
Website Development with PHP and MySQL Introduction.
5/3/2006 Mike/Justin/JYoo AJAX/SOAP/Comet 1 Cleaning up the Internet Using AJAX, SOAP and Comet CS526 Mike Gerschefske Justin Gray James Yoo 02 May 2006.
More APIs: Web Services CMPT 281. Announcements Project milestone Lab: – Web services examples.
Web 2.0 with AJAX Students : LASC Ioana KELEMEN Csilla POP Dan Adrian CIOBANU Dumitru Daniel Project leader : Ahmed RHIAT.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
1 WebSocket & JSON Java APIs Hackday By Somay David
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Introduction to AJAX AJAX Keywords: JavaScript and XML
CGI and AJAX CS-260 Dick Steflik.
AJAX Chat Analysis and Design Rui Zhao CS SPG UCCS.
JavaScript & jQuery the missing manual Chapter 11
XForms: A case study Rajiv Shivane & Pavitar Singh.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
Intro to Ajax Fred Stluka Jan 25, /25/2006Intro to AjaxFred Stluka2 What is Ajax? "Asynchronous JavaScript and XML" New name for an old technique:
Web Application with AJAX CS 526 advanced interned and Web system Presenters Faris Kateb Mohammed AbdulAziz Omar Alzahrani.
AJAX and Atlas in ASP.NET 2.0 William J. Steele MSDN Developer Evangelist Microsoft Corporation
Website Design Lecture 1. Outline Introduction to the module Outline of the Assessment Schedule Lecture Static XHTML, client side and server side Why.
Cross Site Integration “mashups” cross site scripting.
Orbited Scaling Bi-directional web applications A presentation by Michael Carter
(Business) Process Centric Exchanges
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Http protocol Response-request Clients not limited to web browsers. Anything that can access code implementing the protocol works: –Standalone programs.
JSON and A Comparison of Scripts. JSON: JavaScript Object Notation Based on a subset of the JavaScript Programming Language provides a standardized data.
Erlang & Comet Programming 许式伟 2008 年 12 月.
Google Data Protocol Guy Mark Lifshitz. Motivation Google’s Mission: – Organize the world’s information – Make information universally accessible – Provide.
Interprocess Communications
Introduction to Web Services
 AJAX – Asynchronous JavaScript and XML  Ajax is used to develop fast dynamic web applications  Allows web pages to be updated asynchronously by transferring.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
Message Framework Topic subscribe for javascript/flex client.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
Distributed Computing, M. L. Liu 1 Interprocess Communications Mei-Ling L. Liu.
Keith Telle Lead Software Engineer Bit Wizards Behind the Magic: SignalR Demystified.
JavaScript Invented 1995 Steve, Tony & Sharon. A Scripting Language (A scripting language is a lightweight programming language that supports the writing.
JQuery, JSON, AJAX. AJAX: Async JavaScript & XML In traditional Web coding, to get information from a database or a file on the server –make an HTML form.
Open Solutions for a Changing World™ Eddy Kleinjan Copyright 2005, Data Access WordwideNew Techniques for Building Web Applications June 6-9, 2005 Key.
Windows Communication Foundation and Web Services
APACHE TOMCAT WEB SERVER
Research of Web Real-Time Communication Based on WebSocket
Web Programming Language
Physics validation database
The Client-Server Model
Google Web Toolkit Tutorial
AJAX and REST.
AJAX.
Asynchronous Java script And XML Technology
Whether you decide to use hidden frames or XMLHttp, there are several things you'll need to consider when building an Ajax application. Expanding the role.
AJAX.
PHP / MySQL Introduction
웹 푸시 구현 26th UPnL Workshop 김재찬.
DWR: Direct Web Remoting
A Match Made In (Ethereal) Heaven
Introduction to HTML5 and WebSockets.
MIS JavaScript and API Workshop (Part 3)
Introduction to AJAX and JSON
Intro to Ajax Fred Stluka Jan 25, 2006.
J2EE Lecture 13: JMS and WebSocket
Introduction to AJAX and JSON
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Slide 1 What the Bayeux? Filip Hanik SpringSource Inc Keystone, Colorado, 2008

Who is Filip Apache Tomcat committer ASF Member Part of the servlet expert group SpringSource Inc employee

Slide 3 What we will cover Introduction to AJAX and Comet – AJAX yesterday, today and tomorrow – Polling methods – Client support The Bayeux Protocol – Introduction to JSON – Publish/Subscribe

Slide 4 What we will cover The Bayeux Protocol – Message exchange Bayeux clients – Server side – Client side/browser

Slide 5 What we will cover Tomcat Bayeux API – Server side framework for bayeux web applications Implementing a simple app What now, buzz or bull?

Slide 6 Introduction to AJAX What is AJAX – Asynchronous Javascript and XML – Web development technique – Term coined in 2005 – Technique originated from Microsoft 1996 iframe 1999 XMLHttpRequest object

Slide 7 Introduction to AJAX AJAX on the client side – Javascript running in browser – Making HTTP requests in the background – Ability to update without refresh – Must be tailored to the browser – Lots of frameworks out there

Slide 8 Introduction to AJAX AJAX Today – Has become a common solution – Used by more and more large sites AJAX on the server side – Scalability has been an issue – Polling is expensive – Works best when server can do asynchronous processing – Tomcat Comet is such asynchronous engine

Slide 9 Introduction to AJAX Polling and how it works

Slide 10 Introduction to AJAX Client support – Various Javascript frameworks – Communication with browser is still achieved with BIG TIME HACKS!!!

Slide 11 The Bayeux Protocol Publish Subscribe Model – A JSON based publish/subscribe protocol – Development lead by Dojo Foundation – Approach is similar to JMS topics – Still in somewhat of a trial stage – Idea is to have someone else take over the specification

Slide 12 The Bayeux Protocol Publish Subscribe Model – Client and Server side frameworks – Remove complexity of cometd/ajax from web developers – Instead of pub/sub, one can think of it as listening for events

Slide 13 The Bayeux Protocol Introduction to JSON – JavaScript Object Notation – Portable serialization format – Not a markup language – no tags – Fast serialization and deserialization

Slide 14 The Bayeux Protocol Introduction to JSON { "firstName": "John", "lastName": "Smith", "address": { "streetAddress": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": }, }

Slide 15 The Bayeux Protocol Introduction to JSON – JSON compared to XML? Long (and war like) debate JSON doesn’t have tags Much less verbose Parsing libraries much smaller and more efficient – JSON is JavaScript! No parsing needed! – XML with AJAX has been said to be slow.

Slide 16 The Bayeux Protocol Introduction to JSON – Cyclic references are supported in custom format –

Slide 17 The Bayeux Protocol Message exchanges – All message exchange is done using JSON – Very simple Establish client Subscribe to channel Publish events Receive events – Two connection operation (optional) Allows send and receive at the same time

Slide 18 The Bayeux Protocol Message exchanges – Content type for messaging is text/json text/json-comment-filtered – Comment filtered JSON message encapsulated in script comments /* … */ Meant to prevent AJAX hi-jacking But it doesn't, so it has been deprecated.

Slide 19 The Bayeux Protocol Message exchanges – Client establishment is done using handshake [{ "channel": "/meta/handshake", "version": "1.0", "minimumVersion": "1.0beta", "supportedConnectionTypes": ["long-polling", "callback-polling", "iframe"] }]

Slide 20 The Bayeux Protocol Message exchanges – Client establishment is followed by a connect request [{ "channel": "/meta/connect", "clientId": "Un1q31d3nt1f13r", "connectionType": "long-polling" }]

Slide 21 The Bayeux Protocol Message exchanges – To disconnect, simply send disconnect message – Server will also have some sort of timeout in case disconnect message is not received Similar to HTTP sessions [{ "channel": "/meta/disconnect", "clientId": "Un1q31d3nt1f13r", }]

Slide 22 The Bayeux Protocol Message exchanges – Channel subscription is easy – Wild card patterns are supported [ { "channel": "/meta/subscribe", "clientId": "Un1q31d3nt1f13r", "subscription": "/foo/**" } ]

Slide 23 The Bayeux Protocol Message exchanges – Unsubscribing is equally – Wild card patterns are supported [ { "channel": "/meta/unsubscribe", "clientId": "Un1q31d3nt1f13r", "subscription": "/foo/individual-channel" } ]

Slide 24 The Bayeux Protocol Message exchanges – meta channels are used to negotiate between client and server – The only other exchange is sending and receiving events (data)

Slide 25 The Bayeux Protocol Message exchanges – Unsubscribing is equally simple – Wild card patterns are supported [ { "channel": "/meta/unsubscribe", "clientId": "Un1q31d3nt1f13r", "subscription": "/foo/some-channel" } ]

Slide 26 The Bayeux Protocol Message exchanges – Messages are simple key value pair objects public interface Message extends Map

Slide 27 Bayeux actors Clients – Server side and client side – Subscribe to channel – Publish and receive events from channels Browser side clients – Only implementation is the Dojo Toolkit – Have to handshake – Supports different polling methods

Slide 28 Bayeux actors Server side clients (Java) – Implemented in several platforms Tomcat, Jetty, Glassfish – All three use different server side API – Dojo Foundation has been the hinder for a common Java API Lack of process around infrastructure Lack for process around community development

Slide 29 Bayeux actors Server side clients (other) – Effort has been put in place to add APIs in other languages Perl Python.NET

Slide 30 Tomcat Bayeux API Server Side API Goal is to reduce complexity Derived from the original Dojo Java API – Spaghetti references removed – Redundant/ambiguous API removed – More object oriented, instead of converting from string-to-object and object-to-string over and over again

Slide 31 Tomcat Bayeux API API found at Implementation found at Built on top of Tomcat’s CometProcessor org.apache.cometd.bayeux org.apache.tomcat.bayeux

Slide 32 Tomcat Bayeux API Configured through web.xml cometd org.apache.tomcat.bayeux.BayeuxServlet 1 cometd /cometd/*

Slide 33 Tomcat Bayeux API Create a client – Callback is an implementation of the org.apache.cometd.bayeux.Listener interface Bayeux bayeux = ServletContext.getAttribute( “Bayeux.DOJOX_COMETD_BAYEUX”); Client client = bayex.newClient(“client-id”,callback);

Slide 34 Tomcat Bayeux API Subscribe to a channel Channel channel = bayeux.getChannel("/chat/demo",true); channel.subscribe(client);

Slide 35 Tomcat Bayeux API Send a message – Client is the “sender” – Puts the message into the queue for all subscribed clients Message msg = bayeux.newMessage(client); channel.publish(msg);

Slide 36 Tomcat Bayeux API Receive a message – Messages can come in batches – You can reply directly to a client public void deliver(Message[] msgs){ Client sender = msgs[i].getClient(); Message reply = bayeux.newMessage(…); sender.deliver(reply);

Tomcat Bayeux API Building Bayeux Slide 37 svn co tctrunk cd tctrunk

Tomcat Bayeux API Building Bayeux – Tomcat has now been built, build the Bayeux extensions – output/extras contains JARs and sample WAR Slide 38 ant download ant ant –f extras.xml bayeux

Tomcat Bayeux API Simple API Built using Tomcat’s CometProcessor – Scalable – No thread per connection limit – Requires NIO or APR connectors Slide 39

Dojo ToolKit Using the Dojo Toolkit – This is the URL of your Bayeux servlet Slide 40 dojo.require("dojox.cometd"); dojox.cometd.init("/cometd/cometd");

Dojo ToolKit Using the Dojo Toolkit We’ve subscribed to a channel and sent a message – All complexity is behind the scenes Slide 41 dojox.cometd.subscribe("/chat/demo“,onMsgEvent); var evt = {'data': { 'msg': trim(message) + '|' + msg }}; dojox.cometd.publish("/chat/demo", evt.data);

Slide 42 Buzz or Bull? A little bit of both Dojo lacks some of policy, process and infrastructure that ASF has – Good at building user community – Harder to build development community Client side still focuses on the AJAX hacks SPEC changes are fast without SVN notifications!!

Slide 43 Buzz or Bull? Once something like ‘WebSockets’ come in HTML/JavaScript – We can probably expect to see more protocols and frameworks IMHO – Bayeux is still early, it provides some nice features – But we lack more client frameworks – And server API’s vary a lot

Slide 44 And we’re done Thank you! Questions and hopefully Answers