1 / 32

Exploring Real-time apps with ColdFusion and Blaze DS / Live Cycle Data Services ES

Exploring Real-time apps with ColdFusion and Blaze DS / Live Cycle Data Services ES. Dan Blackman www.muddbrick.com. Dan Blackman. Founder and Senior Consultant – Mudd Brick Inc, Dallas, Tx Certified Adobe Instructor – Flex, ColdFusion, Flash

azra
Télécharger la présentation

Exploring Real-time apps with ColdFusion and Blaze DS / Live Cycle Data Services ES

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Exploring Real-time apps with ColdFusion and Blaze DS / Live Cycle Data Services ES Dan Blackman www.muddbrick.com

  2. Dan Blackman • Founder and Senior Consultant – • Mudd Brick Inc, Dallas, Tx • Certified Adobe Instructor – Flex, ColdFusion, Flash • Experience – 12 Years ColdFusion, Flash and Flex

  3. Objectives • Data Persistence: The Why!? • Introducing Live Cycle Data Services • Push vs Pull Messaging • Configuring Message Channel / Destination • Using the Message Service with ColdFusion Event Gateways • Configuring the Event Gateway • Producing and Consuming Messages • Summary and Questions

  4. Data Persistence: The Why!? Why use one over the other!?

  5. Data Persistence: The Why? • ColdFusion Request / Response Applications • Flex Rich Internet Applications • Persisted data is NOT refreshed automatically • Stateful approach to managing data – No more session variables • Refreshed through manual client interactions or Actionscript • Flex Real-time Applications • Persisted Data is refreshed via interactions with server • Stateful approach with server side synchronization • Refreshed through Polling, Long-Polling or RTMP • Data Management Service – Live Cycle service – provides data synchronization between Flex Clients

  6. Data Persistence: The Why

  7. Data Persistence: The Why Let’s take a look at Remote Object and the way it persists data

  8. Introducing Live Cycle Data Services A Quick Look at Live Cycle Data Services – The How?

  9. Introducing Live Cycle Data Services • Live Cycle Data Services ES allows multiple applications to access data from the Flex Framework • Consists of : • Flex Messaging Service • Flex Data Management • Flex Proxy Service • Remote Object Service

  10. Introducing Live Cycle Data Services

  11. Let’s review the Live Cycle Data Services Framework – ColdFusion 8 • Go to c:\ColdFusion8\wwwroot\WEB-INF • web.xml jrun configuration file • flex directory contains config files for LDS • classes directory location for compiled java classes • lib directory location for compiled .jar files

  12. Push vs Pull Messaging Huh?

  13. Push vs Pull Messaging • Many approaches to Data Access: • Simple AMF – Stateful Approach • Client Pull access initiated by user • RTMP – Real Time Messaging Protocol • Maintains persistent connection • Allows real-time communication • Uses Java-NIO facilities – Scalable Solution • Polling – Client Polling • Flex Client sends requests for messages periodically • Uses poll-wait-interval to set the time between requests • Less Scalable solution

  14. Configuring Message Channel / Destination Let’s hit the road running

  15. Configuring a Messaging Channel / Destination Determine how data is transferred to/ from the server by selecting an adapter. • Cfgateway: Messages sent between ColdFusion 8 and Flex Client • JMS adapter: Allows the use of both JMS and Flex clients to communicate • Actionscript Adapter: Flex Default adapter allows only Flex Clients to participate in communication.

  16. Configuring a Messaging Channel / Destination • Most channels are configured out-of-the box • wwwroot/WEB-INF/flex/Services-config.xml • my-cf-amf • cf-polling-amf • cf-long-polling-amf • cf-streaming-amf • cf-rtmp

  17. Configuring a Messaging Channel / Destination <destination id="ColdFusionGateway"> <adapter ref="cfgateway" /> <channels> <channel ref=“my-cfamf"/> <channel ref=“cf-polling-amf"/> </channels> </destination>

  18. Let’s review the Live Cycle Data Services Framework – ColdFusion 8 • Go to c:\ColdFusion8\wwwroot\ • Go to the WEB-INF\flex directory • Open the services-config.xml and messaging-config.xml

  19. Using the Message Service with ColdFusion Event Gateways The server side of things

  20. Using ColdFusion Event Gateways • ColdFusion Event Gateways: • provide communication over protocols other than HTTP. • communicate with various kinds of clients (including Flex Clients). • Server requirements: • ColdFusion Enterprise Edition, version 7.02 or later • LiveCycle Data Services 2

  21. Using ColdFusion Event Gateways • Start by creating a MessageGateway CFC: <cffunction name="onIncomingMessage" returntype="any"> <cfargument name="event" type="struct" required="true"> <!--- Code to handle the data from Flex Client ---> </cffunction> Use the data property to retrieve the data • event.data.body • event.data.headers

  22. Using ColdFusion Event Gateways <cffunction name="sendToFlex" returntype="void" access="public"> <cfargument name=“dataToSend" type=“any" required="true"> <!--- Populate structure with data to send back to Flex. ---> <cfset messageOut.body = dataToSend> <cfset messageOut.headers = structNew()> <cfset messageOut.headers["user"]="ColdFusion"> <cfset messageOut.destination = "ColdFusionGateway"> <!--- Send the structure to Flex. ---> <cfset SendGatewayMessage(“MyAppGateway", messageOut)> </cffunction>

  23. Configuring the Event Gateway The server side of things continued

  24. Configuring the Event Gateway • Configure the Event Gateway after the MessageGateway CFC is created: • Open the ColdFusion Administrator and select Event Gateways > Gateway Instances. • Set the gateway properties as follows: • GatewayID: A unique string identifier • Gateway Type: DataServicesMessaging • CFC Path: The CFC file name and path • Startup Mode: Automatic

  25. Configuring the Event Gateway • Configure the Event Gateway after the CFC is created:

  26. Producing and Consuming Messages Passing Data from Client to Server and back again

  27. Producing and Consuming Messages • Flex uses client-side components to handle publishing and consumption of messages • <mx:Producer …> • <mx:Consumer …> • Work together with messaging services in LCDS • Simply point the Producer and Consumer to a valid Destination

  28. Producing and Consuming Messages • Two ways to Consume messages from a destination: • <mx:Consumer id=“consumer" • destination=“ColdFusionGateway“ message=“messageHandler(event)”/> • import mx.messaging.Consumer; • var crMessagingService:Consumer = new Consumer(); • consumer.destination = “ColdFusionGateway";

  29. Receiving and Processing Mesages • Setting up Channel and Destination via Actionscript: public function initApp():void { • var channel:AMFChannel =    new AMFChannel(“my-cf-amf", "http://127.0.0.1/flex2gateway/");   consumer = new Consumer(); cons.destination = "ColdFusionGateway";   cons.channelSet = new ChannelSet();   cons.channelSet.addChannel(sAMF);   cons.addEventListener(MessageAckEvent.ACKNOWLEDGE, ackHandler);   cons.addEventListener(MessageEvent.MESSAGE, messageHandler);   cons.addEventListener(MessageFaultEvent.FAULT, faultHandler);   cons.subscribe(); } Automatically dispatches a MessageEvent when a message is received

  30. Sending and Receiving Complex Data • On the receiving end, handle the data through the messageHandler. public function handleNotificationsResult (event:MessageEvent):void { facebookNotifications = new XMLListCollection(event.message.body.channel..item); } <mx:DataGrid id=“dgNotifs” dataProvider=“{facebookNotifications}”/>

  31. Let’s Look at some code….Chat ApplicationCollaborative ApplicationData Push Application in ColdFusion

  32. Questions?Dan BlackmanMudd Brick Inc.dblackman@muddbrick.comEvals – mobile.cfunited.com

More Related