ColdFusion 9: Flex Improvements

With the release of the ColdFusion 9 beta I thought I'd share a few of the Flex integration improvements I've been checking out this week. First, ColdFusion 9 now uses Blaze DS to power Flex remoting and messaging. ColdFusion has had remoting support for several versions, but before CF 9 you had to install LCDS or BlazeDS to get Flex messaging. With the move to Blaze DS there is no longer an integrated LCDS Express installation option, so if you want RTMP or data services you will have to buy a separate LCDS license or install the free LiveCycle Data Services ES Single-CPU License version yourself. I know some people feel this is a loss but I'm pretty happy having messaging available out of the box, without the single CPU limitation.

Another big improvement is that ColdFusion now correctly serializes CFC relationships to AMF. Previously, recursive or repeated object references were not correctly serialized. For example, serializing the the following object graph via CF would result in the child object being null for the father object when received in Flex.

family = createObject("component","family");
child = createObject("component","child);
family.mother= createObject("
component","parent");
family.mother.child = child;
family.father = createObject("
component","parent");
family.father.child = child;
return family;

This was a huge issue that made ColdFusion almost unusable for serious OO Flex work. I'm very glad to see this fixed.

Another small enhancement to Flex messaging support is that the CFEventGatewayAdapter now supports selectors for message filtering. So in addition to using subtopics, you can now filter the messages a flex consumer receives based on message header values. For more on message filtering be sure to check out the BlazeDS Developer Guide.

Flex remoting is also reported to be much faster in ColdFusion 9 due to optimizations in the AMF serializing/de-serializing process, although I haven't tested this.

With all the Flex improvements the big thing that is missing from ColdFusion's Flex integration is lazy loading of Hibernate objects. Given how much Adobe is hyping Hibernate ORM support I'm surprised this isn't in ColdFusion 9. It would certainly make a compelling argument for powering your Flex applications with ColdFusion. There are actually a couple of bugs/enhancements logged for this, #76073 and #77738, so if you plan to use the new ORM features with Flex I encourage you to comment or vote on these issues.

Finally, I also ran into one backwards compatibility issue. Previously, when working with the Data Services Messaging Event Gateway the keys to the CFEvent structure passed into the onIncomingMessage event handler were not case sensitive. It seems that in CF 9 the keys in the body of the event are now case sensitive while keys in the event headers are not. I've logged a bug for this, #79712, if you would care to comment or vote.

I'm sure there are a lot of other improvement to ColdFusion 9's Flex integration that I'm missing here so if you know of any, or have any bugs/enhancements you would like to mention, please share.

Comments
Paul Kukiel's Gravatar I really havn't looked at the BlazeDS implementation in CF9 or the docs yet but are you saying I can still "push" data with CF9 as long as I install the single CPU LCDS Express package that came with CF8 ( I assume its available in CF9 ). If not that would be a shame as I use the eventgateways and flexmessaging to push data on our CF8 standard machines and I would hate to loose this when we upgrade to CF9.

I voted for #79712 BTW
# Posted By Paul Kukiel | 7/16/09 12:09 PM
Nathan Mische's Gravatar @Paul - Unless you enabled the RTMP channel, you should see no difference in flex messaging between ColdFusion 8 and ColdFusion 9. (The default destination for both versions, "ColdFusionGateway", use an AMF polling channel with similar configurations.)
# Posted By Nathan Mische | 7/16/09 4:54 PM
Paul Kukiel's Gravatar I have enabled the RTMP channels. I use RTMP and have polling as the fall back. I'm starting to feel like I'm goign to loose the ability to push over RTMP with CF9 ( standard ) I hope this is not the case.
# Posted By Paul Kukiel | 7/16/09 5:00 PM
Nathan Mische's Gravatar @Paul - As far as I know the integrated LCDS installation option is going away in CF 9. You can do real time server push with the HTTP streaming channels available in BlazeDS, or very near real time push with long polling channels.

I compared a LCDS RTMP channel with a BlazeDS long polling channel for a messaging application I did recently and couldn't really tell the difference. We ended up going with BlazeDS and long polling because we didn't have a one CPU server to deploy on. (How does one even get a one CPU server these days?)

Anyway my gut feeling is this: if your messaging application demands RTMP you probably don't want to be running on a one CPU server. If however you were using the data management capabilities of LCDS, then you may want to investigate how to integrate LCDS with ColdFusion.
# Posted By Nathan Mische | 7/16/09 8:46 PM
Paul Kukiel's Gravatar I guess I'm going to have to look at long polling. The app that's using RTMP is a small internal app and it's been excellent for our uses. I feel its a little unfair that this will now be broken on CF9. We don't have the capacity to support ( pay for ) full LCDS at this stage so that's out of the question.

I'm somewhat disappointed about this but I'll investigate alternative methods and perhaps there is a solution there that will fill our needs.
# Posted By Paul Kukiel | 7/17/09 1:54 PM
Nathan Mische's Gravatar To be fair, it won't be broken in CF 9, it will just use an amf polling channel. You can choose to "upgrade" to a long polling or HTTP streaming channel, which CF will have out of the box. For messaging applications I really don't think this change will be a big deal. (Try the long polling or HTTP streaming channels, I think you will be surprised.)
# Posted By Nathan Mische | 7/17/09 2:41 PM
Paul Kukiel's Gravatar Thanks. I appreciate your time. There is so much documentation and so little time and without this post I wouldn't have know about it I will look into your alternatives and I may be back with questions :)
# Posted By Paul Kukiel | 7/17/09 2:53 PM
Roman's Gravatar I hope you can point me in the right direction...

I've been a ColdFusion developer for about 5 years, and can do a lot of cool stuff with jQuery and alike, but time has come for me to have to write my first Flex app, and I'm hoping you might have a few suggestions.

I'm doing research on if it's even possible for me to do what I need. I'm building an app to manage scores for sporting events, and some things like the leader boards, really need to be refreshing in real time. So as new scores come in, they should immediately be reflected on all leader boards, ideally with some animation or highlight that indicates a score just changed. Now the closest thing I've seen to what I need to do were all those CNN, Fox, CNBC apps during the last presidential elections, where as results were coming in the data was automatically pushed to all the connected clients. I don't even know how that works conceptually, is it the server somehow pushing the data to the Flex clients? Cause I don't want every Flex client to have to keep hitting the server every couple of seconds querying for changes like a web page would have to.

Do I even need to use Flex to do this? Can LiveCycle be used with just JavaScript/ColdFusion somehow to do this.

Any help, suggestions, examples are highly appreciated.
Thanks,
-Roman
# Posted By Roman | 10/14/09 4:12 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.