CFUnited Day 1 - CF8 and LiveCycle Data Services - Tom Jordahl

Live Cycle Data Services can be used for RPC, Messaging and Data Management.

There is a free updater to CF7 which does most of this. But in this case you have to install two copies of JRun. One for CF7 and one for Data Services. With CF8 it will be installed with both Standard and Enterprise in same JRun instance, unless you untick the box in the install. It is difficult to update later, so may be worth installing it from the start.

This allows the Live Cycle APIs to be called directly which improves performance. There is no need for the RMI interface that would be required in earlier versions.

Flash Remoting has also been updated and can be used to connect Flex to ColdFusion.

Messaging

Publish and Subscribe allows messages to be broadcast to many clients. In CF8 you can send complex types like structs, arrays and CFCs. ColdFusion can participate as both a publisher and subscriber. Publishing and subscription is done with a Gateway at the CF end of the pipe.

There are now two possible modes of operation, Integrated install or separate JVM install. Configured via messaging-config.xml in the web-inf directory.

Clients publish and consume from a destination that must be set up in the xml file. You can set up multiple destinations. A gateway instance is required for communication and is configured as to which Flex instance it will talk to. You can define a config file to limit connectivity.

You can subscribe to the destination in Flex with mx:Consumer and create messages with mx:Producer tags.

<mx:Consumer id="consumer" destination="ColdFusionGateway"
message="messageHandler" fault="faultHandler(event)"/>


<mx:Producer id="producer" destination="ColdFusionGateway" fault="faultHandler(event)"/>

In CF we call sendGatewayMessage with a struct containing the data.

Gateways are now in CF8 Standard.

There are two ways to connect http and rtmp. http can support many more users than rtmp.

Data Management

Based on RPC and Messaging, allows you to mange distributed data. When data is changed it is propagated to all running clients. It also allows conflict detection between concurrent updates.

It supports nested data relationships and large collections of data and has the ability to notify when the data is changed outside Flex.

In CF8 the speed has been improved and the conversion of data for the tranfer is now done automatically.

Code that actually manages the data is the data manager. You can notify the data manager if the data has changed via a gateway that can be propagated to all the flex clients.

Dataservices can call your CF code. Assemblers can be wriiten as CFCs.

You need the following CFCs to be created.

  • Fill
  • Get
  • Synch
  • Count

There is a new Eclipse wizard to write these for you. This is in the CF extensions for eclipse. It will create the CFCs and AS classes required. This means that you don't have to create all the CRUD yourself.

The alias attribute is used at each end to match the CFCs to AS classes. Both have the same alias so are automatically linked together.

Simple conflict handling is built into the generated code as standard. CF can now check that the update was sucessful.

You have to define channels within the destination, you can use either http: or rtmp: channels in data-management-config.xml where you can link it to a particular CFC.

Tom demonstrated an application where the user would get notified if the data had changed while we were viewing the record. The app was converted from a sample Java version that is shipped with Data Services.

Notification

Now there is an event gateway that can be used to tell Flex that data has changed. Call sendGatewayMessage and pass a struct with the changed data. You don't have to send the data that has not changed.

Optimisation means that Flex keeps track of what you are looking at. Notifications don't happen if you are not looking at that record.

MXML can be compiled inline with CF8. You can use cfimport to add MXML directly inline to your CF pages.

You can compile files on the disk too.

But either of these will be slow. Its good for development but better to use the compiles SWF in production.

Comments
Shawn's Gravatar Good tips on your site, even though they don't fix the problems with Adobe's software upgrades.

I don't know "what" I was thinking but I decided to "upgrade" to Coldfusion 8 with Livecycle Data Services and try out my Flex apps to see if they still worked with the messaging.... NOT !

The so-called "simple" upgrade to use CF8's embedded LifeCycle Data Services has turned into a nightmare !

Problem 1: After setting up the ColdFusionGateway for messaging and compiling the application, it just didn't work, and after Googling around, plenty of folks were having problems, and they suggested downloading and installing the 2.0.1 hotfix, so I did.

Problem 2: Now the debugger gives you errors about "overriding the subtopic". What ? I don't even have subtopics in my messaging..... so after hours of more Googling and finding MANY other people who were having the same problem, a couple of people suggested "remove the library reference to fds.swc from your project because Flex still puts it in there", so I did.

Problem 3: Now it doesn't complain about overriding subtopics anymore, but on startup the faultHandler for the Consumer throws an error about the application needing "FlexClient" support and me needing to recompile the application. What ? I just installed the hotfix SDK and created a new project just to make sure there wasn't anything lingering around, and deleted the fds.swc from the project (if you don't, you go back to getting the override errors). This sucks !

On a side note, if I ignore the consumer faulthandler's message and send the message, I can see by the CF8 administrator that the gateway is in fact receiving the message from Flex and is returning a message back from CF8, which however never gets back to the Flex app.

Too bad I didn't just stay with a STABLE Flex 2.0.1 / CF7.02/ FDS2 environment ! This is now a complete mess...
# Posted By Shawn | 9/6/07 9:06 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.