Blog

  • ColdFusion Event Gateway / Web Service Gave Me Trouble

    My programming love is ColdFusion. I have been working with it since early 1998 with the release of version 3. Version 8 will release next year. A feature of CFMX7 that I have not had the opportunity to use is the Event Gateway to turn a CFC into a web service.

    ColdFusion event gateways are ColdFusion MX elements that let ColdFusion MX react to or generate external events or messages in an asynchronous manner. Event gateways let a ColdFusion application handle information that does not come through an HTTP request. For example, you can use event gateways to handle instant messages, short messages from mobile devices, or messages sent to a TCP/IP port. [Source]

    The Project

    I have a project that uses XML feeds to update inventory status from a wholesaler to the reseller. Unfortunately, do to problems at the wholesaler end, one of the feeds is unavailable and will remain so. The solution is to use a query of the database to obtain IDs of the active products then use CFHTTP to get the information from the wholesaler’s website (site scraping). Since there are roughly 1500 active products at any one time, making 1500 CFHTTP calls at once causes timeouts as the browser gives up before the webserver can finish its task. Since this update will be done only occasionally, 1500 requests to the wholesaler is not a big deal.

    The Solution

    The solution to the problem is to implement the CFHTTP request as a CFC, create a gateway instance with a 5 minute timeout, and call the gateway instance with small groups of product ids from a .cfm page. The concept works beautifully since the Event Gateway is asynchronous and decoupled from the browser which initiated the instance.

    The Problem

    I choose the .cfm to manage grouping the product IDs so that there would only be one query instead of 150 queries (~1500 products in groups of 10) as would happen if the query were within the CFC. So the code builds a list of IDs within a structure (as required by the Event Gateway)

    The onIncomingMessage method must take a CFEvent structure that contains input information in its Data field, and processes the contents of the Data field as needed. [Source]

    The loop that calls the gateway instance builds the list, calls the instance, clears the list, builds the next list, calls the instance, and so forth. Apparently I am able to alter the datastructure so quickly that the second list replaces the first list before the gateway instance fires so the CFC ends up processing only the information from the latter lists. More simply, the CFC processes whatever data is in the structure at the time the gateway event fires from the queue not the state of the structure at the time the gateway event was called by the ColdFusion application. Set up a gateway instance and try the following code. This is the CFC to which the gateway instance will be associated.

    test.cfc

    <cfcomponent displayname="Test Gateway" hint="Logs the idlist passed into the CFEvent.Data structure.">
       <cffunction name="onIncomingMessage" access="remote">
          <cfargument name="CFEvent" type="struct" required="yes">
          <cflog
             text="Gateway test complete for ids #CFEvent.Data.idlist#."
             file="GatewayTest"
             type="Information"
             application="Yes">
       </cffunction>
    </cfcomponent>

    The calling CF application is show below

    test.cfm

    <cfscript>
       datarange = structNew();
       tmplist = "8,1008,1019,1020,1021,1022,1024,1025,1026,1027,1030";

       datarange.idlist = duplicate(tmplist);
       datarange.datasource = "adult";

       status = SendGatewayMessage("TestGateway", datarange);

       tmplist = "8,20,19,18,17,16";

       datarange.idlist = duplicate(tmplist);
       status = SendGatewayMessage("TestGateway", datarange);
    </cfscript>

    You would expect the log file to have two different lines.

    Gateway test complete for ids 8,1008,1019,1020,1021,1022,1024,1025,1026,1027,1030
    Gateway test complete for ids 8,20,19,18,17,16

    but instead it has two identical lines.

    Gateway test complete for ids 8,20,19,18,17,16
    Gateway test complete for ids 8,20,19,18,17,16

    The Solution

    I have not tested the solution yet but I am betting that I either

    1. have to let the CFC call the gateway instance after it has processed a batch of ids thus making this a synchronous process to itself but still asynchronous to the browser or
    2. Create a unique structure for each group of IDs to be processed

    I prefer the latter. Update: Testing is complete and solution #2 works great!

    Other Resources

    About event gateways
    Abobe’s (fomerly Macromedia formerly Allaire) overview
    Deploying an event gateway
    Macrodobellaire’s livedocs for initial setup of an event gateway
    Using the CFML event gateway for asynchronous CFCs
    This was the most helpful livedoc with critical information non-chalantly hidden within such as "Using the CFML event gateway for asynchronous CFCs"
    SendGateWayMessage
    Livedocs for SendGatewayMessage
    The Asynchronous CFML Gateway – A Real-World Example of a Great New Technology
    Matthew Woodward comes through in this ColdFusion Developer’s Journal article
    Understanding Asynchronous Processing by Ben Forta
    It wouldn’t be ColdFusion unless Uncle Ben said something.
    Concurrency Library
    It is very difficult to mention asychronous CFML without someone mentioning Sean Corfield’s work.
    XML Path Language (XPath)
    XPath is a language for addressing parts of an XML document, designed to be used by both XSLT and XPointer.
    XPath Axes
    XML Lessons at W3Schools
  • The 2006 Podcast Awards

    Have you become addicted to podcasts? Want the best? The 2006 Podcast Awards have been announced.

  • User interfaces of the future

    Windows and even the Mac OS are products the 80s. The user interface you use to operate your computer is over two decades old. Is this as good as it gets? John Kheit says change is coming and offers descriptions and links to what could be the computer user interface you use tomorrow.

    Look at pictures of desktops (user interfaces) from 1984 to the present.

  • Fly Naked Air

    I said the future is in nude airlines!

    This video shows we are practically there! (Note: the yahoo interface is obnoxious in that it moves immediately to the next video story. The new airport scanner is the first video). Basically, a machine is almost ready to deloy that will allow airport screens to see you nude and see everything you are packing.

    It’s a virtual strip search…so detailed you can see genitalia.

    So here is my more friendly skies concept. The airports will have rows of changing rooms like you would see in a dressing room at a clothing store. All passengers go into the changing rooms and strip. There is a container that you put your clothes, carry-on, and everything into. Like the doctor’s office bathroom, there is a pass-through which allows your sealed container to move onto a conveyor belt. You don a hospital robe, leave the changing room, and proceed through the metal detectors.

    Taglines for my airline might be "Fly Naked Air" or "The Mile High Club is Open Again" and, my favorite, "Have no fear because you can see what everyone’s packing!" I’m seeking investors!

    See the failed endeavor Hooters Air and The Sun News report on its failure. Wait a minute! Naked-Air (NWS) already flys out of Miami! Here’s a worksafe write-up of Naked-Air including this quote:

    "After 9/11, I didn’t have any cancellations," [Donna Daniels] said. "Even after war broke out, we didn’t have any cancellations on this trip. People feel safe on a flight like this."

  • August Challenge – TGIF (almost)

    I am happy that today is Thursday because I am really looking forward to Friday! I am looking forward to Friday so much that I wish Friday would come twice.

    Can you meet The August Challenge?

  • Explosive Plot Was Ridiculous

    The day they announced that terrorists were planning on blowing up airplanes and were thwarted I devised a wonder conspiracy theory. I love making up conspiracy theories but I don’t take them seriously regardless of how plausible they sound. (I have to link to this amateur video of the 9/11 attacks on the World Trade Center because I opened it in a tab while looking for reopen911.org so all I was getting was sound and I thought I had opened porn…try it. Close your eyes and see if you don’t find yourself turning the speakers down!)

    Anyhow, this computer security specialist says the liquid explosive plot was implausible. Think about how much fuel the airlines will save by the reduced weight of not carrying bottled milk, water and shampoo!

  • Woot-Off today!

    If you don’t know what a Woot-Off is then you probably don’t know what Woot is. Woot is one of those wonderful ideas that makes you slap your forehead and cry out, "why didn’t I think of that!" Woot is associated with Overstock.com and releases 1 product Monday through Friday at 12am Central time (1am Eastern). The product is available in a limited number and often sells out in the first hour. The product is almost always significantly cheaper than anything you find on Froogle.

    A Woot-Off is basically a chance for Woot to clean out their warehouse.

    Woot-Off Light…a short term frenzied mutation of our product posting procedure. In Woot-Off mode, a new product is launched immediately after the sellout of the previous deal. There is a half-Woot-life of 12 hours maximum on any product within a Woot-Off that does not sell out. The number of Woot-Off items, sequence, and quantity will not be announced. When Woot-Off mode is over, the orange lights will disappear and our normal schedule will resume. Depending on its success, this may be a mode we would go into once or twice a month for a relatively short duration of time (24-72 hours generally.) [Source]

    I have purchased twice through Woot and been thrilled each time. Both the products are regularly used and were fantastic bargins. I wish we weren’t in tight budget mode or I would buy my wife the Bluetooth iPod headphones right now. My other favorite bargin hunting site is Slickdeals.net which reports coupon and rebate combinations that often result in wonderful deals or free products. It’s sister site is Slickfillers.net which helps you find low dollar items to push an Amazon order over the $25 mark to gain free shipping.

  • August Challenge – Getting Things Done

    1and1 Webhosting

    I highly recommend my web host. The way it reports statistics in the user control panel is a little weak. I have full access to the server logs and could process them through Webtrends for detailed reporting but it should be easier. I have been procrastinating on installing PhpMyVisites for my wife. Little procrastinations hang over your head and become huge burdens. I finally have a nice statistics report package in place for my wife to monitor her sites!

    Can you meet The August Challenge?

  • Olga Goes Down

    On July 15 I said it was coming. Tom Maszerowski shows us it is here!

    OLGA.net, The On-Line Guitar Archive has been served a take-down notice from the NMPA and MPA (whatever the hell they are) referencing the DMCA as grounds. OLGA’s crime: making text files with the chords of songs available for download. How this violates the DMCA beats me. [Source]

    For those that have have never visited OLGA, it has been around for ages and is an incredible resource for aspiring musicians. For all practical purposes, it is an education site more than anything else. Regular people interpret, not copy, songs showing the guitar chord changes, riffs and lyrics. The site has inspired me to buy CDs by the artists so that I had the actual music to play along as I learned the song.

    This is an atrocity in the name of a lawyer pocketing some dough because the idea that OLGA deprives any artist of revenue is ridiculous. OLGA is a easy target to set a legal precedence in order to tackle the sites that actually make a profit from selling lyrics online.

    ogla offline due to legal takedown notice

  • LOST nears and so do the spoilers

    Hello LOST fans! If this site is to be believed, they have juicy spoilers! So, if you don’t want to see what is coming in Season 3, do not click this link.

  • Mac Converts

    I want a Macbook Pro! Microsoft likes them and so does this guy.

  • The USA Does Not Do World’s Fairs Anymore

    There was a World’s Fair in New Orleans in 1984. That was the last US participation. In 2002, the USA had its membership in the Bureau of International Expositions (BIE – the sanctioning body of the World’s Fair) withdrawn due to non-allocation of funds by Congress. Can you say war funding? The US quietly becomes more egocentric and disconnected from the world. I know I as a citizen did not realize until today that we, as a country, no longer participate in the World’s Fair which dates back to 1851. Way to be a world leader!

    Look for further discussion at Atomic Tumor.

  • A new hobby? Parkour

    Me thinks I have to try Parkour aka PK.

    Parkour (often abbreviated PK) is a physical discipline of French origin in which participants attempt to pass obstacles in the fastest and most direct manner possible, using skills such as jumping, vaulting and climbing, or the more specific parkour moves. The obstacles can be anything in one’s environment, so parkour is often practiced in urban areas because of many suitable public structures, such as buildings, rails, and walls. [Source]

    See also: A much longer description of Parkour. Wikipedia also has a detailed explanation.

  • What is up Google’s sleeve? Photo searches?

    Google, which just launched its free Wifi wireless Internet service in Mountain View but denies plans to create a national free Wifi network, has purchased a photo recognition company.

    We’ve been working to make Picasa (Google’s free photo-organizing software) even better when it comes to searching for your own photos—to make finding them be as easy as finding stuff on the web. Luckily we’ve found some people who share this goal, and are excited that the Neven Vision team is now part of Google. [Source]

    This means that in the future Picasa will not only search your harddrive for pictures but will classify them for you. Perhaps it will recognize all the pictures with granny in them and automatically label them "grandmother" and so forth.

    In other Google news, they have released to beta the first major revamp of Blogger since its aquisition from Pyra Labs in 2003. (oops. That article is from May 10, 2004 Thank you Jonathan Hickman for point it out.) I still hate blogger and advise against using their service due to poor business practices. I was burned by Blogger and lost much writing and advise that you blog using WordPress on a hosted solution. I will happily help anyone setup their very own WordPress blog.

    India has begun blocking Blogger and others such as Typepad. India following in China’s footsteps?

    Update: The striked reference above may have been a typo in the date. C|Net has the same information with an August 15, 2006 publishing date. So, strike the strike. See also Update aims for friendlier Blogger (which they won’t achieve unless they have fixed their customer service issues). From the horse’s mouth at Blogger Buzz with an August 14, 2006 publishing date.