Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 1271

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using External Resources
Debugging event gateway CFCs
When an event gateway CFC responds to an event, it cannot display debugging information in the response page, as
CFM pages do. As a result, many of the normal ColdFusion debugging techniques, including the
available. When you develop event gateway CFCs, consider the following debugging techniques:
• Place trace variables in the Application scope. These variables persist, and you can specify an application name for
your CFC (see
"Application
trace variables, in any CFML page that has the same application name as your CFC.
• Use
tags to help you trace any errors by logging significant events to a file. Also, carefully inspect the
cflog
eventgateway.log and exceptions.log files that ColdFusion maintains. For more information on using the
eventgateway.log file, see
• You can simulate responses from CFCs to the event gateway by using the
page. The function's message parameter should contain the information that the CFC would place in its return
variable.
• If you run ColdFusion from the command line, you can use the Java
messages to the console window, as the following code shows:
<cfscript>
sys = createObject("java", "java.lang.System");
sys.out.println("Debugging message goes here");
</cfscript>
Note: You do not have to restart the event gateway instance when you change a CFC. ColdFusion automatically uses the
updated CFC when the next event occurs.
Example event gateway CFC
The following code shows a temperature scale converter tool that can work with any of several event gateways: SMS,
XMPP, Lotus Sametime, or the example Socket event gateway. Users enter a string that consists of the temperature
scale (F, Fahrenheit, C, or Celsius), a comma, and a temperature on their device. The CFC converts Celsius to
Fahrenheit or Fahrenheit to Celsius, and returns the result.
This example shows how a responder event gateway application can work, and illustrates how different event gateway
types require different outgoing message formats:
<cfcomponent displayname="tempconverter" hint="Convert temperatures between
Celsius and Fahrenheit">
<cffunction name="onIncomingMessage" output="no">
<cfargument name="CFEvent" type="struct" required="yes">
<!--- Standard error message giving the correct input format. --->
<cfset var errormsg = "Please enter scale, integer where scale is F or C,
for example:F, 32">
<!--- Get the message. --->
<cfset data=cfevent.DATA>
<cfset message="#data.message#">
<!--- Where did it come from? --->
<cfset orig="#CFEvent.originatorID#">
<!--- Process the input, generate a message with the new temperature. --->
<!--- Input format is: degrees, temperature. --->
<cfif listlen(message) eq 2>
<cfif (listgetat(message,1) IS "F") OR
(listgetat(message,1) IS "Fahrenheit") OR
scope" on page 1265). You can inspect the Application scope contents, including your
"The eventgateway.log
file" on page 1260.
Last updated 1/20/2012
cfdump
function in a CFM
SendGatewayMessage
method to write
System.out.println
1266
tag, are not

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents