Tom Hensel - Introduction To Amf

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Tom Hensel - Introduction To Amf as PDF for free.

More details

  • Words: 2,625
  • Pages: 36
Adobe MAX 2008 

Introduction to AMF



Wednesday, December 3rd



Tom Hensel

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 1

Terms 

AMF 



Remote Procedure Call (RPC) 



Action Message Format

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 file, 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 ®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 2

Definition 

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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 3

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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 4

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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 5

Specifications 

Adobe Systems published the AMF binary data protocol specification on December 13, 2007 and announced that it will support the developer community to make this protocol available for every major server platform 

Specification of AMF0 download.macromedia.com/pub/labs/amf/amf0_spec_121207.pdf



Specification of AMF3 download.macromedia.com/pub/labs/amf/amf3_spec_121207.pdf

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 6

Benefits - 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 ®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 7

Benefits - 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, ...

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 8

Benefits - Reference Tables 

In AMF 3, Strings, Complex Objects and an Object Type's Traits can be sent by reference 



Complex Objects are defined 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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 9

Benefits - Ease of Use 



Well-documented 

Specifications 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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 10

Benefits - 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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 11

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 fix 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)

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 12

Benchmarks 

Apache JMeter 

Capture AMF packets containing the clients requests first (tcpdump, Charles, ...)



JMeter replays packets and measures response times



Produces nicely looking graphs



Integration in NetBeans (great for J2EE Backend Developers)



Not for beginners!

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 13

Benchmarks 

James Ward‘s „Census“ Benchmark www.jamesward.com/census/ 

Source Code available (GPLv2)



Perfect to convince your bosses that AMF is the right thing



Thanks James!

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 14

Transport - Basic 



No additional Port required 

Most of the time Port 80 is used



No firewall issues on basic setups

Various Transport Channel Types 

Flex SDK offers fine-grained channel configuration



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 performance Using 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)

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 15

Transport - Advanced 



Advanced HTTP and AMF Channels 

‚Piggybacking‘ provides lightweight pseudo polling: Rather than the client channel polling the server on a fixed 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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 16

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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 17

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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 18

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 Features of Cold Fusion



Coming soon!

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 19

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 ®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 20

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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 21

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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 22

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  Certified builds of BlazeDS  Developer and Enterprise Support ®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 23

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 ®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 24

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



Conflict 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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 25

Tools 

Client Development 



Flex SDK is everything you need 

Flex Builder



Flash CS4



Powerflasher FDT



Your choice!

Frameworks 

PureMVC



Cairngorm



Guttershark



Mate



Many, many more

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 26

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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 27

Tools 

Debugging, Testing 

ServiceCapture 



tcpdump 



Similar to Charles but more simple, Shareware

Weapon of choice for UNIX experts (geeks)

WireShark 

Full fledged network analyzer



Captures and dissects mostly everything on the wire



Does not decode AMF

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 28

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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 29

Showcase 

mercedes-benz.de/focus-on-fashion

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 30

Showcase 

mercedes-benz.de/focus-on-fashion

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 31

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

 

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 32

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

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 33

Questions and Answers 

Please ask!

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 34

Keep in touch 

Elephant Seven www.e-7.com



Yeebase Open Source Publishing www.yeebase.com



EMail [email protected]



XING www.xing.com/profile/Tom_Hensel

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 35

®

Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 36

Related Documents

Vantage Amf
December 2019 24
Manifiesto Amf
July 2020 4
Tom
November 2019 52
Zot Amf Catalog
December 2019 26