Flex Remoting and Messaging (2010)

7,248 views

Published on

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
7,248
On SlideShare
0
From Embeds
0
Number of Embeds
34
Actions
Shares
0
Downloads
0
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Flex Remoting and Messaging (2010)

  1. 1. Integrating Flex using AMF<br />Remoting & Messaging in Flex<br />Christopher Grant - crgrant@gmail.com<br /> 1/20/2010<br />
  2. 2. Agenda<br />What is AMF<br />Data Integration Options in Flex<br />Capabilities of AMF<br />Why it is useful<br />Benefits of AMF<br />Where to get it<br />Server Side Options for AMF<br />How to use it<br />Terminology<br />Configuration<br />Examples<br />Simple Remoting<br />Simple Messaging<br />Custom Objects<br />
  3. 3. What is it<br />
  4. 4. Data Integration Options<br />Hyper Text Transfer Protocol – HTTP<br />HTTPService<br />Simple Object Access Protocol – SOAP<br />WebService<br />Action Message Format – AMF<br />Remoting<br />RemoteObject<br />Messaging<br />Consumer<br />Publisher<br />
  5. 5. AMF Capabilities<br />Remoting Services allow your Flex application to directly invoke methods of Java objects deployed in your application server.<br />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. <br />
  6. 6. Why use it<br />
  7. 7. Benefits of AMF<br />Binary transfer is faster than text<br />Objects are very small and are compressed using zlib<br />Fast Serialization/ Deserialization<br />Designed to serialize and deserialize quickly under low memory and slower CPU conditions<br />AMF data is parsed directly into objects, meaning there is no lag for interpretation or parsing<br />ActionScript Object format<br />Support for Native Types and Custom classes<br />
  8. 8. Where to get it<br />
  9. 9. ServerSide AMF Options<br />PHP: Zend, AMFPHP, WebOrb for PHP, SabreAMF<br />Java: BlazeDS*, Red5, GraniteDS*, WebOrb for Java<br />.Net: FluorineFx*, WebOrb* for .Net, AMF.NET<br />Python:PyAMF<br />Ruby on Rails: RubyAMF, WebOrb for Ruby on Rails<br />ColdFusion: Built in*<br />* indicates push / messaging capabilities<br />
  10. 10. How do you use it<br />
  11. 11. Terminology<br />Channel<br />Protocol-based conduits<br />Channel Sets<br />Improves the quality of service in the face of network failures or individual Channel problems<br />Endpoint<br />The server interface responsible for encoding and decoding data into messages<br />Destination<br />Client side reference to resources used for both publish-subscribe and point-to-point messaging<br />Polling vs Streaming<br />Polling opens & closes the connection by message<br />Streaming keeps the connection open at all times<br />
  12. 12. Channels, Set and Endpoints Oh MY!<br />Client<br />Destination<br />EndPoint<br />Channel<br />Streaming<br />Destination<br />Destination<br />EndPoint<br />Channel<br />Streaming<br />Channel Set<br />Destination<br />EndPoint<br />Channel<br />Polling<br />Destination<br />
  13. 13. Configuration<br />Code based<br />AS and MXML<br />Config Files<br />services-config<br />ToolKit<br />Swiz<br />
  14. 14. Config Files<br />Services-config<br />Need to tell flex where it is<br />Setup with IDE Wizard<br />Setup Manually<br />Flex Compiler arguments: -services &quot;C:....”<br />Pointers to <br />remoting-config.xml<br />proxy-config.xml<br />messaging-config.xml<br />Used by Client and Server<br />
  15. 15. Config File Excerpt<br />Services-config.xml<br />…<br />&lt;service-include file-path=&quot;remoting-config.xml&quot; /&gt;<br />…<br />&lt;channel-definition id=&quot;channel-amf“ class=&quot;mx.messaging.channels.AMFChannel&quot;&gt;<br />&lt;endpoint<br />url=&quot;http://{server.name}:{server.port}/{context.root}/messagebroker/amf&quot;<br /> class=&quot;flex.messaging.endpoints.AMFEndpoint&quot; /&gt;<br />&lt;/channel-definition&gt;<br />Remoting-config.xml<br />&lt;service id=&quot;remoting-service“ class=&quot;flex.messaging.services.RemotingService“&gt;<br />…<br />&lt;destination id=&quot;HelloWorld&quot;&gt;<br />&lt;properties&gt; &lt;source&gt;com.grant.Thing&lt;/source&gt; &lt;/properties&gt;<br />&lt;channels&gt; &lt;channel ref=&quot;channel-amf&quot; /&gt; &lt;/channels&gt;<br />…<br />&lt;/destination&gt;<br />…<br />&lt;/service&gt;<br />
  16. 16. Simple MXML Excerpt<br />&lt;mx:RemoteObject<br /> id=“myRemoteObject&quot; <br />destination=&quot;HelloWorld&quot;<br /> result=&quot;resultHandler(event)&quot;<br /> fault=&quot;faultHandler(event)&quot; /&gt;<br />&lt;mx:Buttonlabel=“SayHello“ <br />click=&quot; myRemoteObject.getOperation(“SayHello”).send();&quot; /&gt;<br />private function resultHandler(evt:ResultEvent):void<br />{<br />resultTxt.text= evt.result.toString();<br />}<br />
  17. 17. Real Examples<br />Let’s look at code already…geez!<br />

×