Using Flex Builder 2 you will be able to build complete Flex applications powered by a ColdFusion backend. And you can build them even without using Flex Enterprise Services (FES for short).
But having said that, your application may indeed benefit from FES. We’ll be exposing additional FES functionality in future betas, but for now we have made one important FES capability as simple to use as you’d expect from ColdFusion. I am referring to the ability to push content down to the Flash client without needing the client to poll or refresh on timed intervals. For example, a real-time auction application with price changes reflected as they occur, or a charting application plotting data in real-time, or a management application that shows you the status of users and sessions within your application. FES refers to this functionality as “publish-subscribe”, clients can subscribe to a thread and when data is published they receive it automatically.
The ColdFusion hook into FES is via an event gateway (so yes, this will require ColdFusion Enterprise, and it will also work with the Developer Edition). When the ColdFusion/Flex Connectivity update is installed, a new gateway type called “FlexMessaging” will be added to ColdFusion. You can create instances of this new gateway type to communicate with FES (inbound and outbound).
To help you get started, the following is the simplest possible example of ColdFusion Flex communication via FES, an example of ColdFusion publishing and Flex consuming. It creates a simple HTML form used to post messages which then appear in real-time in a Flex Text box.
Here goes:

  1. This assumes that FES is installed and running (it should be configured
    and running before you start CF).
  2. If you have not yet done so, be sure to enable the CF adapter in
    flex-message-service.xml (in C:fes2jrun4serversdefaultsamplesWEB-INFflex
    if you used the default FES install), here is what one could look like (with
    commented out stuff removed):










    *
    127.0.0.1







  3. It also assumes that you have a gateway defined in CF Admin named
    “Flex2CF” of type FlexMessaging (no config file is needed, and you can point
    to any CFC), and that that gateway is running.
  4. The following is a simple CFM file with a form that self-posts and
    submits to the gateway for processing:








    Message sent.

    Message failed.





    Message:






    document.form1.message.focus();
  5. Create a new project in Flex Builder, be sure to select YES when asked if
    the project will be using Flex Enterprise Services, and create the project under the Flex default server samples folder (C:fes2jrun4serversdefaultsamples if you are using the default installation).
  6. This is the entire Flex app. It is a simple text box which displays the
    received messages. It also shows the connection and subscription state at
    the bottom (they should generally both always be true).








Try it out. You should be able to type messages in the CF page in your web
browser, and they’ll show up in the Flex app.

17 thoughts

  1. Ben, seriously, when are you going to write a book using ColdFusion and Flex? I mean… sheesh! You and your "jet-setting."
    Just kidding! I’m loving this stuff and I’m really into this latest build.
    awesome posts today 🙂

  2. JJ, nope, no plans for a CF/Flex book. Well, not me personally. As much as I’d love to, honestly, I just don’t have the bandwidth for it. Heck, I am months late on the two books I’ve been working on for … um … well … er … a long time. 😉
    — Ben

  3. ben, can FES install under a multiserver cf install (ie use that JRUN)? if so, any blow-by-blow?
    this stuff makes me feel like a kid again 😉

  4. Hello Mr. Forta-Ben !
    Let me first describe what my web application scenario looks like:
    – I want to use CFMX 7+/Scorpio for the backend (services)
    – For the client-side view I want to have the choice between Flash-based and native
    browser-based (that is D(X)HTML + AJAX etc.)
    – I want to serve many concurrent users (1,000, maybe even 10,000 and more) with (near)
    realtime data push; and not only for delivering data centrally from the server, but also
    for multi-user data exchange (not necessarily multimedia data)
    Until now, I have considered using the Flash Media Server 2 (FMS 2) for accomplishing such
    a web application breed; or maybe some other 3rd party multi-user servers.
    Now with the advent of this Flex/ColdFusion solution (Mystic, Flex Enterprise Services,
    Flex Data Services) I ask myself silently: What’s the name of the game ? Which approach could
    be best suited for my scenario from a technological/development standpoint AND a financial
    standpoint ?
    Could You please shed some light on this question ?
    Best Regards
    Kai Tischler aus Verl am schönen Ölbachstrand

  5. Holy crap, this is awesome! I’ve been so sick of writing apps that need to check back with the sever for updates. It got better going from page refreshes to Iframes to AJAX, but still such a waste! I can’t wait to try this stuff out.
    On another note, the FlexMail sample application seems to be gone, along with all of the older showcase apps. Is there some secret place we can go to find those now? If not, could you host the FlexMail app again for us?
    Thanks!
    6dust

  6. Paul, yes, that is the plan, but I don’t know if that is workign yet in the beta. I’ve been using the standalone install for now. So no blow-by-blow yet.
    Kai, FES can do what you want. You may still want Flash Media Server, it depends on what you will be serving. FMS is better suited for streaming audio and video and the like. If what you need to send is data, generated by some back-end processing, then CF+FES may be exactly what you need. You’ll see better clarification on FES vs. FMS shortly.
    6dust, I’ll have them put those examples back up.
    — Ben

  7. I am trying to get this set up locally on CF 7.0.2 Standard. Doesn’t seem to work on CF Standard, correct?

  8. Stefan, FES integration is via Event Gateways which are not supported in CF Standard. I noted this in the original post.
    — Ben

  9. I’m sorry, I must have missed that. This is a shame though as people like myself (who have CF Standard running locally) will have to go back to the Dev Install.

  10. I get false/false.
    And an error on my form indicating,
    " Unable to find Flex adapter for destination "ColdFusionGateway" in the RMI registry on localhost."
    Any thoughts? I haven’t done much with eventgateways prior to this.

  11. Ben, are you saying that the FES stuff won’t work in its own JRun server instance in an existing JRun installation? I *have* to use the separate JRun installation for now? I ask because I installed FES and have it working on its own (http://127.0.0.1:8700/samples works), but the Mystic installer is choking on a "invalid JRun root directory" error and I can’t install it. I’m just wondering if that tidbit is the source of my trouble. I have JRun installed at D:JRun4 rather than C:JRun4, and it doesn’t seem to like that.

  12. Dave, sure it will. You can use FES with an existing J2EE server, or just use the integrated JRun during the beta. I reccomend the latter for now only in that the configuration is simpler, and deploying any future betas will be easier too.
    — Ben

  13. Bah, OK then…back to the drawing board. I simply cannot get the Mystic installer to recognize my D:JRun4 location as a "valid JRun directory root." I posted to the forum set up through the Labs site, but didn’t get any bites.

  14. Ben – sorry to ask such a simple request, but do you think you could update this code for Beta 2? I had it working on our servers before we upgraded, and now I can’t seem to get it to work even if I switch it to http://www.adobe.com/etc.
    (When I try to run it now I get the "Could not resolve <mx:Application> to a component implementation.")

  15. What does destination mean [destination="ColdFusionGateway"]? Is that the URL of the ColdFusion application? How do you tell flex where the server is?

Leave a Reply