• Remoting and


  •   
  • FileName: remoting-messaging-blazeds-flex-fpcc.pdf [read-online]
    • Abstract: Remoting andmessaging with Flex- Stefan Saasen -Flash Platform Code Camp Wellington19/09/2009Samstag, 19. September 2009 Code• http://github.com/juretta/fpcc

Download the ebook

Remoting and
messaging with Flex
- Stefan Saasen -
Flash Platform Code Camp Wellington
19/09/2009
Samstag, 19. September 2009
Code
• http://github.com/juretta/fpcc
• git clone git://github.com/juretta/fpcc.git
• Download: http://github.com/juretta/fpcc/
zipball/master
Samstag, 19. September 2009
Overview
• 15 min each.
• We‘ll talk about: Remoting/RPC, AMF,
Serialization, Messages, Queues, Long-
Polling/Comet, Push vs. Pull.
• AlthoughI‘ll talk about BlazeDS - a lot of
stuff is generic and can be applied to other
technologies as well.
Samstag, 19. September 2009
BlazeDS
• Free & Open Source (LGPL v3)
• Java EE compliant messaging solution
• LifeCycle and BlazeDS share a common
code base.
Samstag, 19. September 2009
BlazeDS
• Reuse existing server-side business logic
• Simple and consistent programming model
to access remote data
• Standard way to push data from server to
client
• Real messaging model to exchange data
between clients and servers
Samstag, 19. September 2009
BlazeDS
BlazeDS
Service
Data Management Adapters
Data Synchronization
LiveCycle
Off-line Applications
Data Paging SQL
RPC Services Hibernate
Web Service
• Flash Remoting
HTTP Service ColdFusion
Remote Object Service
JMS
Messaging
• Messaging Publish & Subscribe Java
Collaboration
Custom…
Real Time Data Push
• HTTP/WebService Proxy Proxy Service
Web-tier Compiler
Portal Deployment
RIA-PDF Generation
Samstag, 19. September 2009
Remoting.
Samstag, 19. September 2009
Samstag, 19. September 2009
RPC
• Inter-process communication.
• Method calls across application/address
space/network boundaries.
• Low level implementation details (network,
lookup, serializatio) are usually hidden -
thus it‘s relatively easy to use.
Samstag, 19. September 2009
Serialization
• Converting objects into a format suitable
for storage (disk) and/or network
transmission
• Often using a binary storage format.
• Also known as marshalling/unmarshalling or
encoding/decoding.
Samstag, 19. September 2009
Samstag, 19. September 2009
AMF
• Action Message Format
• Serialize ActionScript object graphs
• Binary format
• Open standard (published in 12/2007)
• AMF0: Since Flash player 6
• AMF3: Since Flash player 9
Samstag, 19. September 2009
AMF
• Bandwidth and CPU usage lower than:
• XML (SOAP, WDDX, custom XML)
• JSON,YAML
• Send complex objects by reference
• Send a batch of messages in a single
request
Samstag, 19. September 2009
Samstag, 19. September 2009
Demo
Samstag, 19. September 2009
Flex - RemoteObject
Samstag, 19. September 2009
• Compile the service
configuration into the .swf


spring

• Programmatically define
productRemotingService


channel set JavaAdapter ServiceImpl
RemotingDestination
(id="productService")
AMFEndpoint
MessageBroker
BlazeDS
Channel-Set MessageBrokerServlet
Channel Channel Webapplication w/ BlazeDS
SecureAMF AMF Servlet-Container
AMF/AMX over HTTP
Samstag, 19. September 2009
Mapping of data types/
Data Transfer Objects
Java ActionScript
Samstag, 19. September 2009
www.charlesproxy.com
Samstag, 19. September 2009
Messaging.
Samstag, 19. September 2009
Samstag, 19. September 2009
What is messaging?
Samstag, 19. September 2009
Push Pull
Samstag, 19. September 2009
Push Push
Producer Consumer
Samstag, 19. September 2009
Decoupled components
Samstag, 19. September 2009
Messaging
• Tight (method call) vs. loose (messaging)
coupling.
• Loose coupling: „reduce the
assumptions two parties (components,
applications, services [..]) make about each
other when they exchange information. EAI 10
Samstag, 19. September 2009
Messaging
• Event driven model: receive messages
asynchronously
• MessageBroker is responsible for successful
message delivery
Samstag, 19. September 2009
Point-to-Point
Queue (FIFO)
Samstag, 19. September 2009
MessageQueue/
MessageBroker
Producer Consumer
•Route
•Store
•Translate
Samstag, 19. September 2009
Publish-Subscribe
Broadcast
Topic
Samstag, 19. September 2009
Producer Consumer
Publish-Subscribe
Samstag, 19. September 2009
Producer Consumer
Publish-Subscribe
Samstag, 19. September 2009
Demo
Consumer/Producer
Consumer/Producer
Tomcat
Consumer/Producer
Samstag, 19. September 2009









java:comp/env/jms/flex/TopicConnectionFactory

Topic



private function messageHandler(event:MessageEvent):void {
var ne:NotificationEvent = new NotificationEvent(NotificationEvent.SYSTEM_MESSAGE_RECEIVED);
ne.message = (event.message.body as String);
messageDispatcher.dispatchEvent(ne);
}
private function acknowledgeHandler(event:MessageAckEvent):void{
trace(event);
trace(event.message);
}
private function faultHandler(event:MessageFaultEvent):void {
Alert.show("Fault: " + event.faultString, 'Alert Box', mx.controls.Alert.OK);
}
Samstag, 19. September 2009
Server Push using
HTTP???
Client Server Client Server
Any news? Start
Nope
Any news?
Nope
t t
Any news?
Nope
Any news? Message
Nope
Samstag, 19. September 2009
Server Push using
HTTP???
• long polling: Reponse will be „parked“ until data
arrives.
• „streaming“: Infinite chunked response. Each
message will be send as an HTTP response chunk.
• busy polling with piggybacking: If the client sends a
request between scheduled intervals the server
piggybacks any pending messages for the client along
with the reponse
Samstag, 19. September 2009
LiveCycle DS
• NIO based endpoints: Streaming and long
polling. Allows for more parallel
connections, uses a different port.
• RTMP: Real Time Messaging Protocol (TCP
port 1935) - persistent socket connection
for real-time communication.
Samstag, 19. September 2009
Alternative
technologies
• RubyAMF: code.google.com/p/rubyamf/
• AMFPHP: www.amfphp.org
• AMF::Perl
• Python: DjangoAMF, PyAMF
• WebOrb (.Net, PHP, Java, Rails):
www.themidnightcoders.com
• GraniteDS (Java): www.graniteds.org
• RabbitMQ/AMQP
Samstag, 19. September 2009
@juretta
[email protected]
Questions?
code: http://github.com/juretta/fpcc
Samstag, 19. September 2009
Thanks to all sponsors
Samstag, 19. September 2009
Credits
http://www.flickr.com/photos/dmcl/2538280461/sizes/l/
http://www.flickr.com/photos/nathangibbs/3307744005/sizes/o/
http://www.flickr.com/photos/gadl/89650415/sizes/l/
http://www.flickr.com/photos/gasi/441355880/sizes/o/
http://www.flickr.com/photos/gasi/2145086776/sizes/o/
http://www.flickr.com/photos/juretta/3162716948/sizes/o
Samstag, 19. September 2009


Use: 0.1089