Upload
tomhensel
View
124
Download
1
Tags:
Embed Size (px)
Citation preview
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Adobe MAX 2008
Introduction to AMF Wednesday, December 3rd
Tom Hensel
1
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Terms
AMF Action Message Format
Remote Procedure Call (RPC) An inter-process communication technology that allows a computer program to cause a
subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction [wikipedia]
Serialization In computer science, in the context of data storage and transmission, serialization is the
process of converting an object into a sequence of bits so that it can be stored on a storage medium (such as a !le, or a memory buffer) or transmitted across a network connection link. When the resulting series of bits is reread according to the serialization format, it can be used to create a semantically identical clone of the original object [wikipedia]
Often referred to as decoding and encoding of objects
2
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
De!nition
AMF is a binary format based loosely on the Simple Object Access Protocol (SOAP). It is used primarily to exchange data between an Adobe Flash application and a database, using a Remote Procedure Call (RPC)
AMF allows to serialize (and deserialize) ActionScript object graphs
Once serialized an AMF encoded object graph may be used to persist and retrieve the public state of an application across sessions or allow two endpoints to communicate through the exchange of strongly typed data
AMF0 also supports sending complex objects by reference which helps avoid sending redundant instances in an object graph as well as allowing endpoints to restore relationships and avoid circular references
3
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Purpose - AMF0
AMF was introduced in Flash Player 6 in 2001 and remained unchanged with the introduction of ActionScript 2.0 in Flash Player 7. The version header of this format was set to 0 and thus this version of the format is referred to as AMF0
4
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Purpose - AMF3
In Flash Player 9, Action Script 3.0 was introduced along with a new ActionScript Virtual Machine (AVM+) - the new data types and language features made possible by these improvements prompted AMF to be updated
Given the opportunity to release a new version of AMF, several optimizations were also made to the encoding format to remove redundant information from serialized data
This new version of the format is referred to as AMF3
5
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Speci!cations
Adobe Systems published the AMF binary data protocol speci!cation on December 13, 2007 and announced that it will support the developer community to make this protocol available for every major server platform Speci!cation of AMF0
download.macromedia.com/pub/labs/amf/amf0_spec_121207.pdf
Speci!cation of AMF3download.macromedia.com/pub/labs/amf/amf3_spec_121207.pdf
6
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Bene!ts - Efficiency
AMF objects are very small Efficient Encoding and Decoding
AMF data is parsed directly to and from objects
Small Overhead
Binary Format
Optional compression (zlib)
Bandwidth and CPU usage is lower compared to HTML
JSON
YAML
XML
SOAP
WDDX
7
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Bene!ts - Efficiency
Lower bandwidth and CPU usage means Lower latency
Improved User Experience due to quicker response times Key Factor for User Acceptance
Essential for Near-Real-Time-Applications, e.g. Data Processing and Visualization Multi-User Applications Online-Games, MMO Interface and Sensor Input (i.e. Kiosk-Applications)
Bandwidth Usage
Bandwidth is still not free (and maybe never will)
Scales well (no accumulating overhead)
Suitable for low-bandwidth requirements
POTS, ISDN, GPRS, ...
8
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Bene!ts - Reference Tables
In AMF 3, Strings, Complex Objects and an Object Type's Traits can be sent by reference Complex Objects are de!ned as
Anonymous Objects, typed Objects
Arrays
Dates
XMLDocument, XML
ByteArrays
Instead of sending redundant information AMF can simply refer to an earlier occurrence of a complex object
Transparent Reference Caching No Client-side logic required Again, lower bandwidth and CPU usage, lower latency
9
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Bene!ts - Ease of Use
Well-documented Speci!cations available
Many examples and code samples available
Promoted by Adobe (supported)
Easy to implement Most of the work is done automagically
No Parsing required
Less possibly erroneous logic needed Dont Repeat Yourself (DRY)
Strong-typed result objects Syntax Completion everywhere Smooth Team-Work Error handling is included
10
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Bene!ts - Pitfalls
Ubercomplex types can not be serialized DisplayObject
and all of it‘s descendants
Native Types and Custom classes are supported Mapping a AMF serialized object back to a custom class is possible, but
The custom class needs to be instanced when the AMF object is unserialized
Compression (zlib) Lower bandwidth usage, but
Higher latency and CPU usage
Compressing binary data is not as efficient as compressing text (i.e. XML)
Do not use compression on larger chunks of data if near real-time response times are required
11
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Downsides (and workarounds)
Binary Format Not readable by humans
Use a HTTP transport channel for testing, or
Use suitable tools to capture and decode
Less complex clients means a more complex backend Higher skill requirements for the backend developers (J2EE, Python, Ruby, ...)
Client design can not !x faulty backend design
Plan and design both ends carefully and verify your decisions
Create diagrams and documentation
Embrace team-work
Lack of understanding in not-so-agile enterprises Do not push your bosses, convince them by facts (they might save time and money)
12
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Benchmarks
Apache JMeter Capture AMF packets containing the clients requests !rst (tcpdump, Charles, ...)
JMeter replays packets and measures response times
Produces nicely looking graphs
Integration in NetBeans (great for J2EE Backend Developers)
Not for beginners!
13
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Benchmarks
James Ward‘s „Census“ Benchmarkwww.jamesward.com/census/ Source Code available (GPLv2)
Perfect to convince your bosses that AMF is the right thing
Thanks James!
14
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Transport - Basic
No additional Port required Most of the time Port 80 is used
No !rewall issues on basic setups
Various Transport Channel Types Flex SDK offers !ne-grained channel con!guration
Simple AMF or HTTP channels
AMF channels transport data in the binary AMF format and HTTP channels transport data in AMFX, a text-based XML representation of AMF
AMF channels provide better performanceUsing a HTTP channel instead of an AMF channel is only recommended when there are auditing or compliance requirements that preclude the use of binary data
over the network or the contents of messages should be easily human-readable over the network
(debugging)
15
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Transport - Advanced
Advanced HTTP and AMF Channels
‚Piggybacking‘ provides lightweight pseudo polling: Rather than the client channel polling the server on a !xed interval the client sends a non-command message to the server which sends any pending data along with the response to the client message
‚Long-polling‘ sends a request to the server, but a response is not returned to the client until one is available (similar to „Comet“)
Streaming RTMP, AMF, and HTTP channels
Less protocol overhead (connection is kept alive)
RTMP allows message pushing No polling at all Lowest latency
16
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Server Side
PHP PHP Extension
AMFEXT Written in C, fast encoding and decoding of AMF0 and AMF3 messages Looking for a new maintainer since July 2008
PHP Frameworks
AMFPHP Simple and powerful Works since Flash MX 2004 Optional support for AMFEXT
CakeAMFPHP Easy to use with CakePHP, requires AMFEXT Development stalled
17
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Server Side
SabreAMF Server and Client PHP5 only Compliant to PHP Strict Mode
WebORB for PHP Well documented, commercial support available Management Console includes Service Browser, Testing and Security Management Code Generators for ActionScript Remoting, Cairngorm and PureMVC
Zend AMF Easy to use with Zend Framework PHP is very widespread Promoted by Adobe
18
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Server Side
Cold Fusion Supports serialization to AMF
Easy to use
Supported by Adobe
WebORB for Cold Fusion Supports AJAX, Flash, Flex and Silverlight
Provides easy to use interfaces to Featuresof Cold Fusion
Coming soon!
19
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Server Side
.NET amf.net
Implemented as an HttpHandler, easy to install
Very simple
WebORB for .NET
Easy to install (only on Microsoft IIS)
Commercial support available
FluorineFx
Supports RTMP
Template based code generator
Includes a Service Browser
Blaze Data Services for .NET (BlazeDS.NET)
Upcoming port, announced on MAX 2008, stay tuned
20
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Server Side
Python PyAMF
Integration with Python web frameworks like Django, Pylons, Twisted, CherryPy, ... Scales well if used with mod_python, mod_wsgi, ...
Possible to run on Google App Engine
RTMPy is a protocol for Twisted Based on PyAMF Implementing RTMP Still in development
21
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Server Side
Ruby Ruby on Rails
RubyAMF Very easy for Rails Developers to get started Flexible and extensible Scales well if Rails is used with Thin, lighttpd, nginx, Phusion Passenger (mod_rails), ...
WebORB for Rails Based on Ruby on Rails Tight integration of ActiveRecord Commercial support available
RubyIZUMI
RTMP Server for streaming Flash video/audio (H.264)
Based on EventMachine (fast single-threaded socket engine)
Experimental - not ready for production use
22
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Server Side
Java RED5
Mainly for Audio- and Video Streaming
Supports AMF Remoting, too
Blaze Data Services (BlazeDS)
Open Source (GPLv3) Shares codebase (messaging and remoting)
with LiveCycle Data Services SE
Rich set of features
Supports streaming channels over HTTP
Includes Tomcat 6 Application Server (easy to deploy)
LiveCycle Data Services Community Edition Certi!ed builds of BlazeDS Developer and Enterprise Support
23
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Server Side
Granite Data Services (GraniteDS)
Lightweight and stable, scales well
Dedicated Service Factories: integrates with EJB3, Seam, Spring, Guice, Warp, POJO, ...
‚Granite Eclipse Builder‘ for Code Generation in Eclipse
Includes a Client-side framework (‚Tide‘) Service Locator Pattern (inspired by Cairngorm) Offline Data Caching (similar to Live Cycle Data Services ES)
Supports ‚Long polling‘ Data Push over HTTP (‚Gravity‘)
Server-side compilation of MXML (‚Granite Web Compiler‘)
Upcoming support for GlassFish and TopLink (instead of Hibernate)
WebORB for Java
Integrates with Spring, EJB, Pojo, ...
Commerical support available (Enterprise Edition)
Supports Microsoft Silverlight, too
24
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Server Side
Currently, only Adobe LiveCycle Data Services ES implement all protocols, channel types and security options shown Feature Comparison of LiveCycle Data Services ES and BlazeDS
sujitreddyg.wordpress.com/2008/01/31/blazeds-and-lcds-feature-difference/
Adobe LiveCycle Data Services ES Based on J2EE
Very powerful
Data Synchronization
Con%ict Resolution
Offline Data Caching
Very expensive
One-CPU license available for production use (formerly know as LiveCycle Data Services Express); Multi-CPU developer licenses available on request
25
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Tools
Client Development Flex SDK is everything you need
Flex Builder
Flash CS4
Power%asher FDT
Your choice!
Frameworks
PureMVC
Cairngorm
Guttershark
Mate
Many, many more
26
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Tools
Debugging, Testing Firebug
Recommended for every day use
Does not decode AMF
Limited to HTTP (AMFX)
Charles
Multi-protocol local proxy Deciphers SSL/TLS Supports RTMP Decodes AMF
Easy to use
Affordable Shareware
27
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Tools
Debugging, Testing ServiceCapture
Similar to Charles but more simple, Shareware
tcpdump
Weapon of choice for UNIX experts (geeks)
WireShark
Full %edged network analyzer
Captures and dissects mostly everything on the wire
Does not decode AMF
28
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Showcase
Mercedes Benz - Focus on Fashion Server Tiers
Application Server MySQL 5 Ruby on Rails 2.0
ActiveRecord RubyAMF Plugin
Web Server (Assets)
Streaming Server (Videos)
Application
Adobe Flash Platform Application built using Flex 3 SDK
PureMVC Framework (Model-View-Controller Pattern) uses RemoteObject over a AMF channel
Content Modules built in Flash CS3
29
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Showcase
mercedes-benz.de/focus-on-fashion
30
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Showcase
mercedes-benz.de/focus-on-fashion
31
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Showcase
User Experience
Quick response times Server-side caching of database queries Application-side caching
Assets (Browser-Cache) Data (RAM)
Rich and mixed media
Stylish people, fast cars
Developer Experience
Rapid implementation of a prototype
Lightweight application logic
Transparent, strong-typed data model (Value Objects everywhere) Interdisciplinary team-work PureMVC rocks
32
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Summary
Efficiency Enhanced User Experience
Greater User Acceptance
Helps to save the planet (lower energy consumption)
Ease of Use Intuitive way of working with data
Less hassle, higher quality
Have more time for creative ideas, or
Spend more time with your loved ones
AMF is not always the right thing Consider alternatives (E4X, SWX, JSON, ...)
Proof your design by a working prototype
33
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Questions and Answers
Please ask!
34
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Keep in touch
Elephant Sevenwww.e-7.com
Yeebase Open Source Publishingwww.yeebase.com
XINGwww.xing.com/pro!le/Tom_Hensel
35
®
Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
36