CFUnited's day three keynote was given by Vince Bonfanti, President and co-founder of New Atlanta Communications, LLC. Vince spent about half the time giving a high-level overview of BlueDragon and it's pre-history and the rest of the time talking about BlueDragon 7 and the new features contained therein. What follows is my perspective on the new features of BlueDragon 7 based on Vince's presentation and my talks with Josh Adams, Technical Sales Engineer for New Atlanta.
First and foremost, what new features are going to be released in BlueDragon 7? Here's the list as of today:
- Multi-threaded programming support with CFTHREAD and CFJOIN
- CFQUERY enhancements
- CACHEDUNTILCHANGE attribute (available in BD.NET and SQL 2005 only)
- BACKGROUND attribute (for background SQL processing)
- "null" keyword and IsNull() function
- ability to return "null" in CFC methods
- IsNull() for checking for null database values
- CFC interfaces via CFINTERFACE tag
- Application.cfc enhancements
- onClientStart event handler
- onMissingTemplate event handler
- CFDOCUMENT enhancements
- PNG and JPEG output formats (FlashPaper not supported)
- tag will be multi-threaded on all BD editions excluding FREE version
- CFCHART enhancements
- CFCHARTLEGEND, CFCHARTTITLE, and CFCHARTIMAGE tags
- CFSEARCH enhancements
- multiple language support
- Microsoft Wod and PDF support
- CFTIMER tag
- SOAP-related functions
- MySQL 5 support including Stored Procs
- 64-bit Windows and Linux support
- misc performance enhancements
- misc bug fixes
Multi-threading with CFTHREAD and CFJOIN
Multi-threading ColdFusion is not something new. Ever since the release of CFMX 7 developers have had control of ColdFusion's threading via Event Gateways, specifically with the Asynchronous Gateway that's included in CFMX 7 Enterprise Edition. In early 2004 I gave a presentation to the Nashville ColdFusion User Group demonstrating the asynchronous gateway using Damon Cooper's example of creating 100 text files with a 100-thread pool. It was an impressive example then and it's still likely the most used example when demonstrating asynchronous gateways. To BlueDragon's credit, developers have been begging for the ability to manage ColdFusion threads in a simple tag-based or function-based mechanism. Well, now you can. Let's look at some example BlueDragon 7 code:
INSERT INTO Employees
VALUES ('#attributes.firstName#', '#attributes.lastName#')
When this block of code is executed on a BD7 server a new thread will be spawned to handle the insertion query. The page with this code will continue to process without waiting for the query to do its thing. This example illustrates one way to pass data into the newly spawned thread - using attributes to the CFTHREAD tag. Another way to pass data into the thread is by using the Application scope. Note, the newly created thread may last longer or shorter than the initial request thread and therefore has no access to the initial request, session or CGI scopes. This also hints to the fact the new thread has it's own variables scope. If your mind is racing at ways you can use CFTHREAD to quicken up pages by off-loading intensive code to separate threads, you're not alone. But what if you want to create some new threads and have your original request thread tied to them somehow? Well, you can:
<cfset message = "Hello, world">
Just like the previous example, a separate thread will be created to handle the code contained within the CFTHREAD body. In this example we introduce usage of the "name" attribute of the CFTHREAD tag and the CFJOIN tag which tells the main request thread to wait for the nominated thread to finish processing. Once the "separateThread" thread finishes, process will be returned to the main thread where you can access data stored in the separate thread using the syntax [threadname].[variable_name].
Here are some things to think about when using CFTHREAD. You will likely be able to create a large number of threads with the CFTHREAD tag (there will be a limit, but this has not been announced by New Atlanta). You can let some of them process completely on their own or you can write CFJOIN tags to force the main request to wait for one or more of the spawned threads. For instance, you could spawn 4 separate threads with 4 CFTHREAD tags and only wait for one of them to finish before allowing the main request to continue. Perhaps the one thread you are waiting on has data that you need to access in the main request body while the other 3 threads are unrelated and can process entirely on their own.
Another thing to keep in mind is newly created threads occupy the same thread pool as all other threads on your BlueDragon 7 server. This means all new threads WILL impact performance of users browsing pages on the same BD7 server. This implementation is very different from CFMX 7's Asynchronous Gateway where threads created with the gateway occupy a separate thread pool that does not affect normal server usage, i.e. they happen in the background. So while you certainly have some new power with CFTHREAD, use it wisely. Creating too many threads in the main thread pool can impact performance heavily and with some bad code, you could definitely bring down the BD7 server.
EDIT: See comments on this entry as to why I've striked some content here.
I applaud New Atlanta for creating the new multi-threading capability but I think they should seriously look into having the threads run in their own thread pool - something I stressed to Josh Adams. Now, if Adobe would implement a tag-based CFTHREAD developers would have the best of both worlds, the ability to use the asynchronous event gateway (only accessible in the Enterprise edition of CFMX 7) to create additional threads and the use of a more approachable tag-based solution (which could potentially be available in any CFMX 7 edition).
The new feature here to look at is the CACHEDUNTILCHANGE attribute. It's my understanding that this feature is only available due to some new abilities with SQL Server 2005. Specifically, SQL's ability to "watch" certain data and report when it has changed. Hooking this capability to BD7 is the new CACHEDUNTILCHANGE attribute which will essentially cause BD7 to be notified by SQL Server 2005 when the data in the query has changed. When the data has changed and the query with the new attribute is executed, the data will be updated. Otherwise, it will remain the same. This is pretty awesome considering it is very difficult for developers to determine the appropriate time scale for implementing query-based caching with the CACHEDWITHIN attribute. Oftentimes your initial speculation for how long the data should be cached changes thus causing you to edit your code. With BD7's CACHEDUNTILCHANGE attribute these code changes are no longer necessary as you always have real-time, live data with perfect query-based caching.
In addition to the features described above eyebrows were raised during Vince's keynote when he mentioned the IsNull() function for checking null database values and the multi-threaded ability of the CFDOCUMENT tag. I also think the MySQL 5 support is pretty cool. With all these new features and the ability of CFML to run on the .NET platform I believe responsible developers should look into BlueDragon 7. In the least, developers should be aware of what's out there and what alternatives there are to CFMX 7. I'm not endorsing Blue Dragon 7 with this article, I'm just helping get the information out there so people can be more tuned-in to the ColdFusion community and the products and tools available to ColdFusion development. If you're interested in learning more aboug BD7 the beta is slated to start later this month (or in August) with product release currently scheduled for October of this year.