User Guide

Table Of Contents
Using the example event gateways and gateway applications 1043
Example DirectoryWatcher application
The following code shows a simple directory watcher application. It enters a line in a log file each
time a file is added, deleted, or changed in the directory specified in the configuration file.
ColdFusion MX includes the date and time that a log entry is made. However, if the directory
watcher monitors changes infrequently, for example once every minute or more, the time in the
log entry might differ from the time a file was added or changed, so the information includes the
time (but not date) for these actions.
<cfcomponent>
<cffunction name="onAdd" output="no">
<cfargument name="CFEvent" type="struct" required="yes">
<cfset data=CFEvent.data>
<cflog file="MydirWatcher" application="No"
text="ACTION: #data.type#; FILE: #data.filename#;
TIME: #timeFormat(data.lastmodified)#">
</cffunction>
<cffunction name="onDelete" output="no">
<cfargument name="CFEvent" type="struct" required="yes">
<cfset data=CFEvent.data>
<cflog file="MydirWatcher" application="No"
text=" ACTION: #data.type#; FILE: #data.filename#">
</cffunction>
<cffunction name="onChange" output="no">
<cfargument name="CFEvent" type="struct" required="yes">
<cfset data=CFEvent.data>
<cflog file="MydirWatcher" application="No"
text=" ACTION: #data.type#; FILE: #data.filename#;
TIME: #timeFormat(data.lastmodified)#">
</cffunction>
</cfcomponent>
JMSGateway
The JMSGateway class acts as a Java Messaging Service consumer or producer. The source for this
event gateway is located in gateway/src/examples/JMS. The gateway requires a configuration file,
which is in gateway/config/jmsgateway.cfg. For full documentation of the configuration options,
See the configuration file. The ColdFusion MX Administrator lists the compiled gateway (which
is included in the gateway\lib\examples.jar file) on the Gateway Types page.
Note: The ColdFusion MX Administrator uses JMS as the gateway type name for the JMSGateway
class.
Using the JMS Gateway as a consumer
The JMSGateway class creates a subscriber to the topic specified in the configuration file. The
gateway consumes the following types of messages:
Te xt Me s sa g e
BytesMessage containing raw UTF-8 text