<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fusioncube &#187; coldfusion</title>
	<atom:link href="http://www.fusioncube.net/index.php/category/servers/coldfusion/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fusioncube.net</link>
	<description>The online journey of a technophile, by Steve Brownlee</description>
	<lastBuildDate>Tue, 31 Aug 2010 13:34:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Getting pages of results from Oracle</title>
		<link>http://www.fusioncube.net/index.php/getting-pages-of-results-from-oracle</link>
		<comments>http://www.fusioncube.net/index.php/getting-pages-of-results-from-oracle#comments</comments>
		<pubDate>Wed, 19 May 2010 18:36:53 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[paging]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=867</guid>
		<description><![CDATA[I learned something new today.&#160; Using ROWNUM in an Oracle query, while it does limit the resultset to the number specified, does not limit it to the top n results.&#160; It’s basically a random sample because it appears that ROWNUM is calculated before the ORDER BY clause. I’ve got a set of data that’s thousands, [...]]]></description>
			<content:encoded><![CDATA[<p>I learned something new today.&#160; Using ROWNUM in an Oracle query, while it does limit the resultset to the number specified, does not limit it to the top <em>n</em> results.&#160; It’s basically a random sample because it appears that ROWNUM is calculated before the ORDER BY clause.</p>
<p>I’ve got a set of data that’s thousands, upon thousands in size that will choke any browser if I try to send the complete set as a JSON string and try to render it, so I’m attempting to page the results.</p>
<p>What I ended up having to do is two-subselects in order to get the paging right.</p>
<pre class="code"><code>&lt;cffunction name="getByAttributes" access="public" output="false" returntype="query"&gt;
	&lt;cfargument name="attr1" type="numeric" required="false" /&gt;
	&lt;cfargument name="attr2" type="string" required="false" /&gt;
	&lt;cfargument name="attr3" type="string" required="false" /&gt;
	&lt;cfargument name="page" type="numeric" required="false" default="1" /&gt;

       &lt;cfset var local = {} /&gt;
	&lt;cfset local.rowEnd = arguments.page * 100 /&gt;
	&lt;cfset local.rowStart = ((arguments.page - 1) * 100) + 1 /&gt;

       &lt;cfquery name="local.pagedQuery" datasource="#variables.datasource.getName()#"&gt;
       SELECT
           y.attr1
           y.attr2,
           y.attr3,
       FROM (
           SELECT
               x.attr1,
               x.attr2,
               x.attr3
               rownum r
           FROM (
               SELECT
                   fi.attr1,
                   fi.attr2,
                   fi.attr3
               FROM funny_info fi
               ORDER BY fi.attr2
           ) x where rownum &lt;= &lt;cfqueryparam cfsqltype="cf_sql_integer" value="#local.rowEnd#" /&gt;
       ) y where r &gt;= &lt;cfqueryparam cfsqltype="cf_sql_integer" value="#local.rowStart#" /&gt;
       &lt;/cfquery&gt;

	&lt;cfreturn local.pagedQuery /&gt;
&lt;/cffunction&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/getting-pages-of-results-from-oracle/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion DSN Listing</title>
		<link>http://www.fusioncube.net/index.php/coldfusion-dsn-listing</link>
		<comments>http://www.fusioncube.net/index.php/coldfusion-dsn-listing#comments</comments>
		<pubDate>Thu, 25 Feb 2010 22:12:15 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[coldfusion dsn serviceFactory]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=786</guid>
		<description><![CDATA[Speaking of ColdFusion DSNs, here&#8217;s a fun code snippet. Want to see a list of DSNs that are currently set up on a box? &#60;cfscript&#62; factory = createObject("java", "coldfusion.server.ServiceFactory").DataSourceService; sources = {}; sources = factory.getDatasources(); &#60;/cfscript&#62; &#60;cfdump var="#sources #" /&#62; Pretty simple.]]></description>
			<content:encoded><![CDATA[<p>Speaking of ColdFusion DSNs, here&#8217;s a fun code snippet.  Want to see a list of DSNs that are currently set up on a box?</p>
<pre class="code"><code>&lt;cfscript&gt;
factory = createObject("java", "coldfusion.server.ServiceFactory").DataSourceService;

sources = {};
sources = factory.getDatasources();
&lt;/cfscript&gt;

&lt;cfdump var="#sources #" /&gt;</code></pre>
<p>Pretty simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/coldfusion-dsn-listing/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion DSN-free Oracle Connections</title>
		<link>http://www.fusioncube.net/index.php/coldfusion-dsn-free-oracle-connections</link>
		<comments>http://www.fusioncube.net/index.php/coldfusion-dsn-free-oracle-connections#comments</comments>
		<pubDate>Thu, 25 Feb 2010 21:55:23 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[coldfusion oracle dsn jdbc]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=781</guid>
		<description><![CDATA[Figured this one out by sheer, dumb luck. &#60;cfscript&#62; driverManager = createObject("java","java.sql.DriverManager"); conn = driverManager.getConnection("jdbc:macromedia:oracle://111.11.11.111:1521;SID=mySID;serverName=111.11.11.111;user=**********;password=**********"); stmt = conn.createStatement(); recordSet = stmt.ExecuteQuery("select * from table order by 1 desc"); results = createObject("java", "coldfusion.sql.QueryTable").init(recordSet); &#60;/cfscript&#62; &#60;cfdump var="#results#"&#62; The trick was to add the username and password as properties of the connection string rather than having them inline. [...]]]></description>
			<content:encoded><![CDATA[<p>Figured this one out by sheer, dumb luck.</p>
<pre class="code"><code>&lt;cfscript&gt;
driverManager = createObject("java","java.sql.DriverManager");

conn = driverManager.getConnection("jdbc:macromedia:oracle://111.11.11.111:1521;SID=mySID;serverName=111.11.11.111;user=**********;password=**********");

stmt = conn.createStatement();
recordSet = stmt.ExecuteQuery("select * from table order by 1 desc");
results = createObject("java", "coldfusion.sql.QueryTable").init(recordSet);
&lt;/cfscript&gt;

&lt;cfdump var="#results#"&gt;</code></pre>
<p>The trick was to add the username and password as properties of the connection string rather than having them inline.</p>
<p>This fails</p>
<pre class="code"><code>driverManager.getConnection("jdbc:macromedia:oracle:username/password/111.11.11.111:1521;SID=mySID;serverName=111.11.11.111;")</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/coldfusion-dsn-free-oracle-connections/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Application and Client Specific Messaging in Flex</title>
		<link>http://www.fusioncube.net/index.php/application-and-client-specific-messaging-in-flex</link>
		<comments>http://www.fusioncube.net/index.php/application-and-client-specific-messaging-in-flex#comments</comments>
		<pubDate>Mon, 01 Feb 2010 17:51:08 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[event gateways]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[messaging]]></category>
		<category><![CDATA[recommended]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=706</guid>
		<description><![CDATA[I&#8217;ve had a task I assigned to myself open for some time now. I needed to figure out how to implement Flex/ColdFusion messaging for our clients. There were three (3) criteria for success: It needed to integrate seamlessly with our existing Cairngorm Extensions It needed to allow for application level messages It needed to allow [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a task I assigned to myself open for some time now.  I needed to figure out how to implement Flex/ColdFusion messaging for our clients.  There were three (3) criteria for success:</p>
<ol>
<li>It needed to integrate seamlessly with our existing Cairngorm Extensions</li>
<li>It needed to allow for application level messages</li>
<li>It needed to allow for client specific messages</li>
</ol>
<p>The trick was to create an abstract class that multiple departments could use, because internally we use ColdFusion, Java and .NET to produce and consume messages.  In our department, we use ColdFusion, so I had to create a concrete implementation of the abstract class called ColdFusionMessagingDelegate which handles the construction and publication of an AsyncMessage to a ColdFusion Event Gateway.</p>
<p>Other departments&#8217; implementation of this process will be different, so I couldn&#8217;t force an implementation in the abstract class.</p>
<p>Additionally, in the application I was using for testing, I wanted to have two categories of messages:</p>
<ol>
<li>Messages intended to be produced and consumed by individual clients</li>
<li>Messages intended to be consumed by any client</li>
</ol>
<p>To that end, I created another abstract class at the application level that simply passed along specific a Flex Producer and Consumer for each category. I then created two concrete classes.  One specified the Producer and Consumer for the application, and the other specified the Producer and Consumer for that individual client.</p>
<p>Here&#8217;s a diagram showing the architecture.</p>
<div id="attachment_718" class="wp-caption alignnone" style="width: 762px"><a href="http://www.fusioncube.net/wp-content/uploads/2010/02/GenericMessagingArchitecture.png"><img src="http://www.fusioncube.net/wp-content/uploads/2010/02/GenericMessagingArchitecture.png" alt="Generic Messaging Architecture" title="Generic Messaging Architecture" width="564" height="457" class="size-full wp-image-718" /></a><p class="wp-caption-text">Generic Messaging Architecture</p></div>
<p>So far, it&#8217;s working great in the development test lab, but I still need to get with my colleagues for a group code review and hopefully fine tune the code and the architecture a bit more.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/application-and-client-specific-messaging-in-flex/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Another ColdFusion Death</title>
		<link>http://www.fusioncube.net/index.php/another-coldfusion-death</link>
		<comments>http://www.fusioncube.net/index.php/another-coldfusion-death#comments</comments>
		<pubDate>Sun, 15 Nov 2009 04:21:06 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=688</guid>
		<description><![CDATA[A bit closer to home this time. My family&#8217;s company back home has been running a ColdFusion-powered site that I wrote for them yyeeeeaaarrrsss ago. My sister, who is now running the marketing department, wants to do an overhaul of the site, because it has been yyeeeeaaarrrsss since the first version. Obviously, I&#8217;m not available [...]]]></description>
			<content:encoded><![CDATA[<p>A bit closer to home this time.</p>
<p>My family&#8217;s company back home has been running a ColdFusion-powered site that I wrote for them yyeeeeaaarrrsss ago.  My sister, who is now running the marketing department, wants to do an overhaul of the site, because it <strong>has</strong> been yyeeeeaaarrrsss since the first version.</p>
<p>Obviously, I&#8217;m not available to help them out full time &#8211; y&#8217;know, being four states away with a wife and two kids and all &#8211; and she&#8217;s found it impossible to find anyone with ColdFusion skills back in Pittsburgh.  She&#8217;s made the decision to use PHP as the technology for the new site.</p>
<p>Kinda speaks for itself there.</p>
<p>Weird that I&#8217;ve been a small time evangelist for ColdFusion all these years and recently all I&#8217;ve been hearing about is how people are deciding to not use it any more.</p>
<p>What&#8217;s going on?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/another-coldfusion-death/feed</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Another ColdFusion Shop Bites the Dust</title>
		<link>http://www.fusioncube.net/index.php/another-coldfusion-shop-bites-the-dust</link>
		<comments>http://www.fusioncube.net/index.php/another-coldfusion-shop-bites-the-dust#comments</comments>
		<pubDate>Thu, 12 Nov 2009 18:13:57 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=685</guid>
		<description><![CDATA[Was speaking with a friend back home today who works for a very large financial institution. They currently have a major investment in the Adobe stack of technologies, including ColdFusion. However, the decision was recently made &#8211; as usual, at a business level &#8211; to become a Microsoft shop. One of the critical elements in [...]]]></description>
			<content:encoded><![CDATA[<p>Was speaking with a friend back home today who works for a very large financial institution.  They currently have a major investment in the Adobe stack of technologies, including ColdFusion.  However, the decision was recently made &#8211; as usual, at a business level &#8211; to become a Microsoft shop.</p>
<p>One of the critical elements in this was the fact that ColdFusion developers, specifically highly talented ones that can architect enterprise level applications, simply did not exist in the marketplace.  There are too few of them, and they are all currently employed, and the cost of developing someone of this caliber was simply too high and would take too long.</p>
<p>I&#8217;ve read far too many times in the past 12 years about how Allaire/Macromedia/Adobe does not make the appropriate efforts to get the ColdFusion development platform into the hands of kids early, when they are learning development, so that when these kids coming out of college enter the workforce they know Microsoft or Java technologies, or both, and then may possibly, occasionally, touch upon a couple of features of the ColdFusion platform years later.</p>
<p>The result is more and more business decision makers not even considering it as an option.  Technology aside here people, look at it from a business perspective.  Ok, fine, ColdFusion is a great platform.  It has lots of features and is easy to learn.</p>
<p>So what?</p>
<p>I need to hire 9 people <strong>right now</strong> who have vast, deep experience in building mission critical applications that perform at the highest level, scale with the organization and the user base, and are extensible so that we can keep making it better.</p>
<p>Having gone through this process many times myself&#8230; I&#8217;m sorry but ColdFusion doesn&#8217;t cut it.  I love the platform, I love the people, and the community, but if I got funding to build a major application or system, and needed a large, experienced development team, I would not choose ColdFusion.</p>
<p>Now, once the system got off the ground and the underlying architecture was solid and we needed to start expanding the system, making sub-projects from it, then sure I&#8217;d consider hiring a few ColdFusion developers because you can build applications very quickly with and perform some integrations more easily.</p>
<p>Bottom line is that, while I&#8217;m sad to see another promising ColdFusion shop being slowly dismantled over the next two years, I can&#8217;t say I disagree with the decision.</p>
<p>It sucks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/another-coldfusion-shop-bites-the-dust/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>ColdFlash!</title>
		<link>http://www.fusioncube.net/index.php/coldflash</link>
		<comments>http://www.fusioncube.net/index.php/coldflash#comments</comments>
		<pubDate>Wed, 14 Oct 2009 12:29:30 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=670</guid>
		<description><![CDATA[I see a trend happening at Adobe that I believe others may be detecting but no one has come out and said it yet. This trend will have a significant impact on software engineers who are experienced and/or committed to the Adobe stack of technologies &#8211; specifically to ColdFusion developers. I have seen the question, [...]]]></description>
			<content:encoded><![CDATA[<p>I see a trend happening at Adobe that I believe others may be detecting but no one has come out and said it yet. This trend will have a significant impact on software engineers who are experienced and/or committed to the Adobe stack of technologies &#8211; specifically to ColdFusion developers.</p>
<p>I have seen the question, &#8220;Why do I need to learn Flex?&#8221;, floating around for about two years now from many ColdFusion developers.  These dedicated folks have noticed the ongoing trend of companies moving their user interfaces from straight HTML/Javascript to Flex.</p>
<p>Aside from noticing the trend being enough of a motivator to learn Flex (and it should be), the trend at the technology level should be additional motivator.</p>
<h3>Blurring the Lines</h3>
<p>The reason I entitled this article ColdFlash! is that I believe that by the time ColdFusion 11 is released to the public, the lines between ColdFusion and the Flash Platform will be practically eliminated to the point where entire applications can be written in the Actionscript language.  ColdFusion will simply be another package available to Actionscript developers, much the same as data visualization.</p>
<p>Let&#8217;s take a look at some of the things that led me to this conclusion.</p>
<ul>
<li>Back in ColdFusion MX 7, the ability to <a href="http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001493.htm">use ColdFusion on server-side Actionscript</a> was introduced.</li>
<li>ColdFusion 8 greatly enhanced the ability to integrate ColdFusion with Actionscript applications with the inclusion of LCDS Lite, or using BlazeDS.</li>
<li>The ability to use ColdFusion functionality from Actionscript is finally marketed with ColdFusion 9, which, to me, indicates that Adobe is going to start expanding on this.</li>
<li>Enhanced Flash Remoting in ColdFusion 9.  BlazeDS installed by default with the ability to upgrade to LiveCycle Data Services 2.6.1</li>
</ul>
<h3>A World of RIA</h3>
<p>The era of static web applications is coming to an end.  Everywhere you look, there are Flex web sites, Flex web applications, Flex business applications, iPhone apps, Android apps, AJAX sites and applications, and even Silverlight (but since this is an Adobe related article, we won&#8217;t focus on &#8220;that&#8221; technology).</p>
<p>Using these technologies allows developers to create interactive, responsive, intelligent, and user-friendly applications that people actually enjoy using &#8211; because in the end that&#8217;s what it&#8217;s all about.  I&#8217;ve seen many apps created that perfectly fulfill the requirements established for it, but are disliked by the users because of the technical restrictions the old world of HTML placed upon it.</p>
<p>Of course, we&#8217;re still living in the world of HTTP, but with Adobe&#8217;s AMF protocol, it&#8217;s not as painful because our payloads have been drastically reduced &#8211; which increases responsiveness even further.</p>
<p>I believe what I&#8217;m trying to get at here is that RIA can no longer be considered a fad, a passing fancy, or a dead-end trend.  Just like technologies such as ASP, ColdFusion and PHP completely transformed the Internets from a vast collection of non-interactive HTML pages into a data-aware, responsive universe, the RIA trend is the child of that revolution. Applications can now not only present data, but present it more quickly, more intelligently and in a more visually engaging way.</p>
<p>If you are ColdFusion developer, and not even considering learning some of the technologies is what is now called the Flash Platform, you are ensuring your continuing progression towards being along the same career path of a COBOL programmer.  Granted, that&#8217;s an extreme example, and may not be accurate, but it conveys what I&#8217;m trying to get across.</p>
<h3>It&#8217;s Still J2EE</h3>
<p>For me, the most powerful feature of working with ColdFlash is that it&#8217;s all built on the Java platform.  You could have Java developers, and ColdFlash developers in the same organization with no loss in productivity or community.  </p>
<p>In fact, one of the things we&#8217;ve been considering in my team is the possibility of coverting some of our heaviest ColdFusion Components into Java code to increase our performance (sidebar: Let&#8217;s go ColdFusion team!  We need even more speed on CFC creation) when sending back large arrays of objects to our Flex clients.</p>
<h3>It&#8217;s Time to Evolve</h3>
<p>In conclusion, I want to say that I don&#8217;t believe ColdFusion as a language is going away, Adobe has proven that it&#8217;s going to be a core component of the Flash Platform, but I do believe it is going to evolve into ColdFlash and that the best career move that ColdFusion developers can make right now is to learn Flash, AIR, and Flex.</p>
<p>In 2-3 years when the Flash Platform becomes more integrated, employers are going to be looking for the whole package, not just a ColdFusion developer, and not just an Actionscript developer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/coldflash/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Tutorial: Flex and ColdFusion Communication via Event Gateways</title>
		<link>http://www.fusioncube.net/index.php/tutorial-flex-and-coldfusion-communication-via-event-gateways</link>
		<comments>http://www.fusioncube.net/index.php/tutorial-flex-and-coldfusion-communication-via-event-gateways#comments</comments>
		<pubDate>Tue, 09 Jun 2009 17:16:11 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[event gateways]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[recommended]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=606</guid>
		<description><![CDATA[How to set up ColdFusion event gateways for communicating with Flex.]]></description>
			<content:encoded><![CDATA[<h1>1&nbsp;&nbsp;&nbsp;Preface</h1>
<p>At work, we&#8217;re investigating using ColdFusion Event Gateways to handle certain complex types of communication between our Flex user interfaces and ColdFusion, so yesterday I jumped on Google and started researching and ran into some <a href="http://www.fusioncube.net/index.php/coldfusion-event-gateway-for-flex-messaging">roadblocks</a>.  However, after some monkeying around and more poring over of documentation and articles, I finally got a basic example working.</p>
<p>As usual, now that I&#8217;ve discovered how to set up a somewhat advanced feature of a platform, I&#8217;m sharing the knowledge in a comprehensive article.  The documentation available for getting ColdFusion and Flex to communicate via event gateways was scattered, incomplete, or incomprehensible.  In many of the articles, there were a lot of words, but little or no code, which does not help developers at all.  Don&#8217;t tell me how it works, SHOW me how it works.</p>
<h1>2&nbsp;&nbsp;&nbsp;Creating a ColdFusion Listener Component</h1>
<p>The listener component is the ColdFusion code that will receive any message sent from your Flex client via the DataServicesMessaging gateway type in your ColdFusion admin (more on that later).  The basic structure is simple &#8211; just need one method named onIncomingMessage() in your component.</p>
<p>Create a file called InterceptFlex.cfc somewhere in your webroot and put the following code in it.</p>
<h3>InterceptFlex.cfc</h3>
<pre class="code"><code>&lt;cfcomponent output="false"&gt;
   &lt;cffunction name="onIncomingMessage" returntype="any"&gt;
         &lt;cfargument name="event" type="struct" required="true" /&gt;

	&lt;/cffunction&gt;
&lt;/cfcomponent&gt;</code></pre>
<h1>3&nbsp;&nbsp;&nbsp;Setting Up Your Event Gateway</h1>
<p>Now you need to go to your ColdFusion Administrator so that you can create an event gateway that specifies that any message coming in on a certain destination will be sent to the InterceptFlex component.</p>
<h2>3.1&nbsp;&nbsp;&nbsp;Destinations</h2>
<p>There is a destination already set up for you in the \WEB-INF\flex\services-config.xml file (or \WEB-INF\flex\messaging-config.xml file if you are running BlazeDS) called ColdFusionGateway, and we&#8217;re just going to use that for this example.</p>
<p>You just need to make one change for this sample application to work.  Open up the XML file and find the ColdFusionGateway destination.  In the &lt;properties&gt; block add the following server property:</p>
<pre class="code"><code>&lt;properties&gt;
   &lt;server&gt;
      &lt;durable&gt;false&lt;/durable&gt;
      &lt;allow-subtopics&gt;true&lt;/allow-subtopics&gt;
   &lt;/server&gt;

   ...
&lt;/properties&gt;</code></pre>
<h2>3.2&nbsp;&nbsp;&nbsp;Gateway Setup</h2>
<p>Now, go to the Gateway Instances section of your ColdFusion Administrator and start creating a gateway.  </p>
<ol>
<li>The gateway ID can be anything, and you can just call it &#8220;test&#8221; for now.</li>
<li>Select <em>DataServicesMessaging</em> as the type.</li>
<li>The CFC path is the physical path to your InterceptFlex.cfc file you created.</li>
<li>the configuration file is located in the <em>\WEB-INF\cfusion\gateway\config\</em> directory, and you can use the one already set up named <em>flex-messaging-gateway.cfg</em>.  So find that file and enter the path here.</li>
<li>Click the <em>Add Gateway Instance</em> button.</li>
<li>Start the gateway instance you just created.</li>
</ol>
<h1>4&nbsp;&nbsp;&nbsp;Sending Messages From Flex</h1>
<p>This application is a slight modification from the code provided in the Adobe article <a href="http://www.adobe.com/devnet/flex/articles/intro_fms.html">Introduction to the Flex Message Service</a>, which I highly recommend you read if you&#8217;re new to Flex Messaging.</p>
<p>Create a new Flex application called <strong>Chat</strong> and paste this code into the <em>Chat.mxml</em> file. This code will connect to the ColdFusionGateway destination and send the message object to ColdFusion.  ColdFusion, in turn, uses the event gateway instance we set up to send that object to the <em>onIncomingMessage()</em> method of the <em>InterceptFlex.cfc</em> component.</p>
<pre class="code"><code>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
    pageTitle="Simple Flex Chat" creationComplete="createChat()"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[

        import mx.messaging.Consumer;
        import mx.messaging.Producer;
        import mx.messaging.events.MessageAckEvent;
        import mx.messaging.events.MessageFaultEvent;
        import mx.messaging.events.MessageEvent;
        import mx.messaging.messages.AcknowledgeMessage;
        import mx.messaging.messages.AsyncMessage;
        import mx.utils.ObjectUtil;

        private var chatPublisher:Producer;
        private var chatSubscriber:Consumer;

        private function createChat():void
        {
            chatPublisher = new Producer();
            chatPublisher.addEventListener(MessageFaultEvent.FAULT, onProducerFault);
            chatPublisher.destination = "ColdFusionGateway";

            chatSubscriber = new Consumer();
            chatSubscriber.addEventListener(MessageAckEvent.ACKNOWLEDGE, onConsumerAck);
            chatSubscriber.addEventListener(MessageEvent.MESSAGE, receiveChatMessage);
            chatSubscriber.destination = "ColdFusionGateway";
            chatSubscriber.subtopic = "simpleChat";
            chatSubscriber.subscribe();
        }

        private function onProducerFault(faultEvent:MessageFaultEvent):void
        {
            output.text += "[Error: " + faultEvent.message.toString() + "]\n";
        }

        private function onConsumerAck(ackEvent:MessageAckEvent):void
        {
            output.text += "[Got ack for subscribe or unsubscribe operation]\n";
        }

        // Note: these are the event-handling methods from above, now moved into the separate source file:

        private function sendChatMessage():void
        {
            var msg:AsyncMessage = new AsyncMessage();
            msg.body = input.text;
            msg.headers["username"] = "Me";
            msg.headers["gatewayid"] = "test";
            chatPublisher.subtopic = "simpleChat";
            chatPublisher.send(msg);
            input.text = "";
        }

        private function receiveChatMessage(msgEvent:MessageEvent):void
        {
            var msg:AsyncMessage = AsyncMessage(msgEvent.message);
            output.text += msg.headers["username"] + ": " + msg.body + "\n";
        }
        ]]&gt;
    &lt;/mx:Script&gt;

    <!-- UI Declarations -->
    &lt;mx:Panel title="Simple Flex Chat"&gt;
        &lt;mx:TextArea id="output" width="500" height="220" /&gt;
        &lt;mx:TextInput id="input" width="500" enter="sendChatMessage()" /&gt;
        &lt;mx:ControlBar horizontalAlign="center" width="500"&gt;
            &lt;mx:Button id="clearBtn" label="Clear" click="output.text =''" /&gt;
        &lt;/mx:ControlBar&gt;
    &lt;/mx:Panel&gt;

&lt;/mx:Application&gt;</code></pre>
<h1>5&nbsp;&nbsp;&nbsp;Respond to the Flex Client</h1>
<p>Now that ColdFusion has received the message, we&#8217;re simply going to respond back.  You can enhance this to do anything you wish &#8211; send out emails, update database tables, log messages &#8211; but for now we&#8217;re just going to send a message back that let&#8217;s the Flex client know that the mechanism works.</p>
<pre class="code"><code>&lt;cfcomponent output="false"&gt;
   &lt;cffunction name="onIncomingMessage" returntype="any"&gt;
      &lt;cfargument name="event" type="struct" required="true" /&gt;

      &lt;cfscript&gt;
      x = structNew();
      x.body = "hello right back at ya";
      x.destination = "ColdFusionGateway";
      x.headers = structNew();
      x.headers['username'] = "System";
      x.headers['DSSubtopic'] = "simpleChat";
      x.lowercasekeys = "yes";
      &lt;/cfscript&gt;

      &lt;cfreturn x /&gt;
   &lt;/cffunction&gt;
&lt;/cfcomponent&gt;</code></pre>
<p>One of those esoteric details that took me forever to find out was how to apply a subtopic to a message in ColdFusion.  In Flex, it&#8217;s absurdly simply, you simply say <em>message.subtopic = &#8220;myTopic&#8221;;</em>, but in ColdFusion, you have to set a header key named DSSubtopic with the topic name (see above).</p>
<h1>6&nbsp;&nbsp;&nbsp;Conclusion</h1>
<p>To be safe, restart your ColdFusion instance, then fire up the simple Flex chat app and type in a message.  After a few seconds, you will receive a message from System in the history box.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/tutorial-flex-and-coldfusion-communication-via-event-gateways/feed</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>ColdFusion Event Gateway for Flex Messaging</title>
		<link>http://www.fusioncube.net/index.php/coldfusion-event-gateway-for-flex-messaging</link>
		<comments>http://www.fusioncube.net/index.php/coldfusion-event-gateway-for-flex-messaging#comments</comments>
		<pubDate>Mon, 08 Jun 2009 19:43:55 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[blazeDS]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=592</guid>
		<description><![CDATA[Update I&#8217;ve resolved the issue described in this article and wrote a tutorial based on my research: Tutorial: Flex and ColdFusion Communication via Event Gateways Problem I&#8217;ve run into a snag getting ColdFusion to send messages to a destination set up for Flex Messaging. I&#8217;ve gone through all the tutorials and set up an event [...]]]></description>
			<content:encoded><![CDATA[<h1>Update</h1>
<p>I&#8217;ve resolved the issue described in this article and wrote a tutorial based on my research:<br />
<a href="http://www.fusioncube.net/index.php/tutorial-flex-and-coldfusion-communication-via-event-gateways">Tutorial: Flex and ColdFusion Communication via Event Gateways</a></p>
<h1>Problem</h1>
<p>I&#8217;ve run into a snag getting ColdFusion to send messages to a destination set up for Flex Messaging.  I&#8217;ve gone through all the tutorials and set up an event gateway in my local admin using the FlexMessaging type&#8230;<br />
<a href="http://www.fusioncube.net/wp-content/uploads/2009/06/flex_messaging_cf_gateway.png"><img src="http://www.fusioncube.net/wp-content/uploads/2009/06/flex_messaging_cf_gateway-300x156.png" alt="flex_messaging_cf_gateway" title="flex_messaging_cf_gateway" width="300" height="156" class="alignnone size-medium wp-image-593" /></a></p>
<p>but any attempt to send a message to it&#8230;.</p>
<pre class="code"><code>x = structNew();
x.body = "hello world";
x.destination = "ColdFusionGateway";
sendGatewayMessage("test", x);</code></pre>
<p>results in the following message&#8230;</p>
<pre class="code"><code>Unable to find the Flex adapter for destination ColdFusionGateway
 in the RMI registry on localhost:1099.

The Flex adapter may not be running or the destination may be incorrect.

The error occurred in C:\ColdFusion8\servers\cfusion\cfusion-ear\cfusion-war\webapps\test\scribble.cfm: line 24

22 : x.body = "hello world";
23 : x.destination = "ColdFusionGateway";
24 : sendGatewayMessage("test", x);
25 :
26 :&lt;/cfscript&gt;</code></pre>
<p>I have modified my ColdFusion server to run BlazeDS, and I&#8217;m hoping that is not the issue.  I&#8217;ll perform a clean installation and see if it works that way.  The strangest thing about this is that when I send a message from a Flex client to the same destination, it finds the adapter just fine (this is all set up on a ColdFusion application server) so the fact that FMS works, but ColdFusion Event Gateways don&#8217;t is troubling.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/coldfusion-event-gateway-for-flex-messaging/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Using Flex Message Service with ColdFusion and BlazeDS</title>
		<link>http://www.fusioncube.net/index.php/using-fms-with-coldfusion-blazeds</link>
		<comments>http://www.fusioncube.net/index.php/using-fms-with-coldfusion-blazeds#comments</comments>
		<pubDate>Thu, 23 Apr 2009 17:13:39 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[blazeDS]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=504</guid>
		<description><![CDATA[Actually, it *almost* has nothing to do with ColdFusion, it&#8217;s just that I have ColdFusion setup on my machine and that&#8217;s the server I use with Flex apps. For a ColdFusion server, the WEB-INF\flex\messaging-config.xml file has an additional adapter &#8211; called cfgateway &#8211; set up as default adapter for destinations. &#60;adapters&#62; &#60;adapter-definition id="cfgateway" class="coldfusion.flex.CFEventGatewayAdapter" default="true" [...]]]></description>
			<content:encoded><![CDATA[<p>Actually, it *almost* has nothing to do with ColdFusion, it&#8217;s just that I have ColdFusion setup on my machine and that&#8217;s the server I use with Flex apps.</p>
<p>For a ColdFusion server, the WEB-INF\flex\messaging-config.xml file has an additional adapter &#8211; called cfgateway &#8211; set up as default adapter for destinations.</p>
<pre class="code"><code>&lt;adapters&gt;
    &lt;adapter-definition id="cfgateway" class="coldfusion.flex.CFEventGatewayAdapter" default="true" /&gt;
    &lt;adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter"/&gt;
    &lt;adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/&gt;
&lt;/adapters&gt;</code></pre>
<p>So when I created a destination for the quick chat application used in the <a href="http://www.adobe.com/devnet/flex/articles/intro_fms.html">Introduction to the Flex Message Service article</a> on the Adobe Developer Connection site, it was using the cfgateway adapter by default and causing all kinds of havoc when I tried to run the app.</p>
<p>Therefore, if you are using ColdFusion, just make sure you specify the actionscript adapter when you create destinations for FMS in your messaging-config.xml file.</p>
<pre class="code"><code>&lt;destination id="MyTransientTopic"&gt;
   &lt;adapter ref="actionscript" /&gt;
   &lt;properties&gt;
      &lt;server&gt;
         &lt;durable&gt;false&lt;/durable&gt;
      &lt;/server&gt;
   &lt;/properties&gt;
   &lt;channels&gt;
      &lt;channel ref="java-polling-amf"/&gt;
   &lt;/channels&gt;
&lt;/destination&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/using-fms-with-coldfusion-blazeds/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
