Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Remoting & Messaging in Flex

Remoting & Messaging in Flex

Columbus Flex Enthusiasts - Presentation of Remoting & Messaging in Flex with AMF

Avatar for Christopher Grant

Christopher Grant

January 20, 2010
Tweet

More Decks by Christopher Grant

Other Decks in Programming

Transcript

  1. Agenda — What is AMF — Data Integration Options in

    Flex — Capabilities of AMF — Why it is useful — Benefits of AMF — Where to get it — Server Side Options for AMF — How to use it — Terminology — Configuration — Examples — Simple Remoting — Simple Messaging — Custom Objects
  2. Data Integration Options — Hyper Text Transfer Protocol – HTTP

    — HTTPService — Simple Object Access Protocol – SOAP — WebService — Action Message Format –AMF — Remoting — RemoteObject — Messaging — Consumer — Publisher
  3. AMF Capabilities — Remoting Services allow your Flex application to

    directly invoke methods of Java objects deployed in your application server. — Message Services provide a publish/subscribe infrastructure that enables your Flex application to publish messages and subscribe to a messaging destination, enabling the development of real-time data push and collaborative applications.
  4. Benefits of AMF — Binary transfer is faster than text

    — Objects are very small and are compressed using zlib — Fast Serialization/ Deserialization — Designed to serialize and deserialize quickly under low memory and slower CPU conditions — AMF data is parsed directly into objects, meaning there is no lag for interpretation or parsing — ActionScript Object format — Support for Native Types and Custom classes
  5. ServerSide AMF Options — PHP: Zend, AMFPHP, WebOrb for PHP,

    SabreAMF — Java: BlazeDS*, Red5, GraniteDS*, WebOrb for Java — .Net: FluorineFx*, WebOrb* for .Net, AMF.NET — Python: PyAMF — Ruby on Rails: RubyAMF, WebOrb for Ruby on Rails — ColdFusion: Built in* * indicates push / messaging capabilities
  6. Terminology — Channel — Protocol-based conduits — Channel Sets —

    Improves the quality of service in the face of network failures or individual Channel problems — Endpoint — The server interface responsible for encoding and decoding data into messages — Destination — Client side reference to resources used for both publish-subscribe and point- to-point messaging — Polling vs Streaming — Polling opens & closes the connection by message — Streaming keeps the connection open at all times
  7. Channels, Set and Endpoints Oh MY! Destination Destination EndPoint Channel

    Channel Set Client Destination EndPoint Channel Polling Streaming Destination Destination EndPoint Channel Streaming
  8. Configuration — Code based — AS and MXML — Config

    Files — services-config — ToolKit — Swiz
  9. Config Files — Services-config — Need to tell flex where

    it is — Setup with IDE Wizard — Setup Manually — Flex Compiler arguments: -services "C:\....” — Pointers to — remoting-config.xml — proxy-config.xml — messaging-config.xml — Used by Client and Server
  10. Config File Excerpt Services-config.xml … <service-include file-path="remoting-config.xml" /> … <channel-definition

    id="channel-amf“ class="mx.messaging.channels.AMFChannel"> <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint" /> </channel-definition> Remoting-config.xml <service id="remoting-service“ class="flex.messaging.services.RemotingService“> … <destination id="HelloWorld"> <properties> <source>com.grant.Thing</source> </properties> <channels> <channel ref="channel-amf" /> </channels> … </destination> … </service>
  11. Simple MXML Excerpt <mx:RemoteObject id=“myRemoteObject" destination=" HelloWorld " result="resultHandler(event)" fault="faultHandler(event)"

    /> <mx:Button label=“SayHello“ click=" myRemoteObject.getOperation(“SayHello”).send();" /> private function resultHandler(evt:ResultEvent):void { resultTxt.text = evt.result.toString(); }