ColdFusion 9: onCFCRequest and Flash Remoting

ColdFusion 9 introduced the new onCFCRequest method. Unfortunately, this new method breaks Flash Remoting requests. To get around this issue you can resort to a modified version of the old onRequest hack. If you have an Application.cfc that covers remote components that will be used for Flash Remoting, you can add the following to your onRequestStart method:

<cffunction name="onRequestStart">
<cfargument name="targetPage" />

<cfif findNoCase("/flex2gateway",arguments.targetPage) gt 0>
<cfset structDelete(variables,"onCFCRequest") />
<cfset structDelete(this,"onCFCRequest") />

This will remove the onCFCRequest method for the current request and allow your Flash Remoting call to work. (Note: you may need to search for different paths depending on your BlazeDS endpoint configurations. If you don't know what I'm talking about here you will most likely be fine with the default "/flex2gateway".)

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.


CFEventGatewayAdapter and Selectors

Lately I've been doing a lot of work with Flex messaging using ColdFusion and BlazeDS. Recently I was trying to get message filtering working using the Flex Consumer component's selector property. After a few false starts I found that I just couldn't get selectors to work using either BlazeDS or LCDS.


BlazeDS Consumer Selector Gotcha

When working with Flex messaging, a Consumer component can filter the messages it receives using a selector. The selector uses SQL 92 syntax to filter against message headers, so if my messages contained a header named roomID I could write something like:

myConsumer.selector = "roomID = 1";

The problem I ran into today was that I wanted to filter on multiple values using an IN clause, however when I tried to do the following I got no messages:

myConsumer.selector = "roomID IN (1,2,3)";

Turns out that I needed to modify my IN statement to filter for string values as opposed to numeric values:

myConsumer.selector = "roomID IN ('1','2','3')";

This was a little confusing because I was able to filter on single values using numeric values, as in my first example above, but filtering on multiple values required string values. I'm using BlazeDS with ColdFusion, so I'm not sure if this is specific to my configuration, but if you run into issues trying to filter on numeric values using an IN clause, try using strings instead.

UPDATE: After further testing I'm not entirely sure that selectors work at all with the ColdFusion Event Gateway Adapter. I'm still trying to work this out, but right now the first example above doesn't seem to be working for me, even if I check for a string value. If anyone has experience using selectors with CF please let me know...

BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.