Interview for Using Event Gateways with CFMX7
      "Using Event Gateways with CFMX7" interview with Jeff Tapper
Michael Smith: This time we are talking with Jeff Tapper about his CFUNITED-05
talk "Using Event Gateways with CFMX7". So why should a developer come to your
session Jeff ?

Jeff Tapper: One of the most exciting new features of CFMX7 is event gateways.
With these, we suddenly have the ability to run ColdFusion code without the need
for a web request first.  This opens up the world of possibilities in ways not
previously considered.  For instance, we can now trigger a CFC based on an SMS
message, or on a new file being added to the file system.

MS: What is an SMS message and why would I want to use one with my CF app?

JT: SMS is the Short Message Service, the protocol behind text messages sent
between cell phones.  Using CFMX7 and SMS together we can do things like notify
a site administrator of errors and warnings, or as we saw at MAX this year, a
survey application can accept votes from SMS messages on cell phones anywhere.

MS: That is cool! What is the CF code to do this like?

Its actually a pretty simple CFC.  Something like this:
[cfcomponent displayname="makeRequest" hint="Handles SMS based song requests for
Radio Free Astoria"]
[cffunction name="onIncomingMessage" output="no"]
  [cfargument name="CFEvent" type="struct" required="yes"]
  [!--- Get the message ---]
  [cfset data=cfevent.DATA]
  [cfset message=data.message]
  [cfobject component="rfa.artist" name="artist"]
  [cfset success = artist.makeRequest(message)]
  [!--- where did it come from? ---]
  [cfset orig=CFEvent.originatorID]
  [cfset retValue = structNew()]
  [cfset retValue.command = "submit"]
  [cfset retValue.sourceAddress = arguments.CFEVENT.gatewayid]
  [cfset retValue.destAddress = arguments.CFEVENT.originatorid]
[cfif success]
  [cfset retValue.shortMessage = "Your Request of: " & message & " has been
  [cfset retValue.shortMessage = "There was a problem submitting your request.
Please try again later"]
  [!--- send the return message back ---]
  [cfreturn retValue]

MS: So it is just a regular CFC?

JT: It is, the only thing special about it is that its methods are automatically 
passed the CFEVENT argument, which describes the incoming event.

MS: So can one CF gateway message trigger another one?

JT: Absolutely, since its possible to both send and receive gateway events, we 
can fire any event we like, any time CFML is executed.  This can allow for 
clever applications like a IM to SMS gateway, where an incoming Instant Message 
can be broadcast back out to a phone via SMS.  In my session, I'll be 
demonstrating a feature I'm building for Radio Free Astoria, to allow users to 
request a song via Instant Messenger.  Traditionally, song requests were simply 
triggering an email to me, but the new version can also trigger an SMS or IM 
message to me, depending on my settings.

MS: Cool. Sounds like it opens up a whole new way for async programming events 
for CF that was previous only available to Java programmers! Is this as powerful 
as JMS (Java Messaging Services)?

JT: You will have to come to my talk to find out!

MS: ok, I am looking forward to seeing you at CFUNITED
Home  |  About  |  Topics  |  Speakers  |  Exhibitors  |  Register  |  News  |  Travel
© Copyright TeraTech Inc 2004. All rights Reserved.