Notes: Improved Flash Remoting and Adobe AIR Integration in ColdFusion 9

These notes are taken at Adobe MAX 2009.

You can use HTTPService, WebService, RemoteObject components in Flex to pull data in different ways. Now what about ColdFusion 9?

ColdFusion’s Flash Remoting has been improved. So Flash applications that have ColdFusion 9 as a backend will interact much faster, and it can handle circular references.

There is now direct data translation between ActionScript and CF types, instead of previously having an intermediate Java layer that handled this. This involves changes in services-config.xml, but no code changes are required in your apps. Support for the old style remoting is still present for backward compatibility.

So how much faster is it? Drastically faster. Easily x9 faster, and that increases as the number of transactions occurs, according to the whitepaper Adobe has released about it.

BlazeDS. ColdFusion 9 is now integrated with BlazeDS as the default installation.

Configuration File. Services-Config.xml is now split into 4 files. There are a handful of ColdFusion-specific properties under the channel definition now. An “enable-small-messages” property is there and should be set to “false”. This is important for the new Flash Remoting in CF9, because BlazeDS’s default is “true”.

There is an AMFChannel component in Flex for the new Flash Remoting (Note: You can alternatively tell the AMFChannel component to have enableSmallMessages=”false”). Finally, the endpoint class is changed for the new CF9 one.

Offline AIR apps with ColdFusion 9

Now the fun stuff. ColdFusion 9 has an ORM for AIR! Build offline AIR apps without the SQL mess and conflict handling. There is a CF-AIR persistent framework for SQLite on the client side. CF keeps track of all updates to local database and synchronizes with the server, including conflict resolution.

By having ORM on the client- and server-side, these two are integrated through the CF-AIR persistent framework.

In the application code for the demo, there were customer.cfc and address.cfc persistent objects. Then a sync CFC is used for providing the fetch and sync functions for communication with the AIR client.

Step #1: Create the persistent CFCs.

Step #2: Create the sync CFC. He called it custmgr.cfc. The CFC has implements=”ISyncManager” as an attribute. Then you have fetch() and sync() methods that handle the transactions. Here you can provide your logic for handling certain scenarios, such as conflicts.

Step #3: On client side, create equivalent AS classes that map to the CFC via the [RemoteClass(alias="")] metadata tag.

Step #4: Use the CF-built AIR libraries provided to fetch data from server, with the SyncManager component. It’s very simple, practically just point it to the sync CFC and do a fetch() method. To work with the database, you then openSession() and can create new AS objects and call save() on the session to insert/update/etc. Finally, using commit() will commit the results and invoke the sync() process.

On the client side, it can receive conflict notification and receive both versions of the data so that you can decide what to do with the conflict.

It is very exciting to have some help implementing synchronization without having to purchase LCDS. Using the CF9/AIR integration libraries will be very nice.

5 Responses to “Notes: Improved Flash Remoting and Adobe AIR Integration in ColdFusion 9”

  1. TJ Downes Says:

    While now on par with the speed of Railo remoting, remoting is still not fast enough in CF.

    Simply put, instantiation of CFCs, while greatly improved, is still slow. Some significant re-engineering needs to be done to CF if it is ever to be considered a serious platform for OO development. While I love CF, these limitations have forced me to seriously consider Groovy or Java instead of CF as the model layer for large-scale or data intensive Flex applications. Fortunately I am hearing rumors that you can use Groovy as the model with CF9 ORM. If this turns out to be possible, hopefully it will eliminate the bottleneck caused by CFC instantiation.

  2. Albert Says:

    I am starting to read about and play around with Blazeds and ColdFusion. I was looking for an example to test out conflict resolution with a ColdFusion CFC and Flex. Do you know of any example code I am able to test. Any help is greatly appreciated.

  3. recovery data Says:

    This is great and interesting that ColdFusion’s Flash Remoting has been improved, so Flash applications that have ColdFusion 9 as a backend will interact much faster, and it can handle circular references.

  4. Jennifer L Says:

    Love the new header :D

  5. Josh Says:

    Thanks! Now if I only blogged anymore! :-D

  Theme Brought to you by Directory Journal and Elegant Directory.