
1320
DEVELOPING
COLDFUSION 9 APPLICATIONS
Using External Resources
Las
t
upda
te
d 8/5/2010
Creating Custom Event Gateways
Adobe ColdFusion lets you create event gateways. Building a gateway requires a knowledge of Java programming,
including Java event-handling and thread-handling concepts, and of the technology to which you are providing the
gateway, including the types of messages that you handle. This documentation also assumes that you have a thorough
knowledge of ColdFusion development concepts and practices, including ColdFusion components (CFCs).
Event gateway architecture
A ColdFusion event gateway listens for events and passes them to ColdFusion for handling by the application listener
CFC or CFCs. It must implement the coldfusion.eventgateway.Gateway interface, and use the ColdFusion
GatewayServices class. The following image expands on the basic event handling architecture diagram to show how a
ColdFusion event gateway works:
Receiving messages:
The event gateway listener thread receives events from an external event source such as a socket
or SMSC server, and calls the GatewayServices
addEvent
method to send a
CFEvent
instance to ColdFusion.
Sending messages:
The ColdFusion event gateway service calls the
outgoingMessage
method of the event gateway
and passes it a CFEvent instance with the destination and message information. The event gateway forwards the
message as appropriate to the external receiver.
The event gateway architecture is not limited to handling messages from external sources, such as SMS devices or IM
clients. It can also be used to handle events that are internal to the local system or even the ColdFusion application.
Also, a gateway does not have to implement two-way communications.
The sample directory watcher gateway provided with ColdFusion is an example of an internal, one way, gateway. It
has a single thread that periodically checks a local directory and sends a message to a CFC when the directory contents
change. This gateway does not support outgoing messages. (The code for this gateway is in the
gateway/src/examples/watcher directory.)
Another internal gateway, the asynchronous CFML gateway, is provided as part of the ColdFusion product. Unlike
most gateways, it does not have a listener thread. Its
outgoingMessage
method gets messages from CFML
SendGatewayMessage
functions, and dispatches them to a CFC
onIncomingMessage
method for handling. This
gateway lets ColdFusion support request-free asynchronous processing. For more information on using this gateway,
see “
Using the CFML event gateway for asynchronous CFCs
” on page 1269.
Applicat
External event
generator /
receiver
External event
generator /
receiver
Listener thread
addEvent
method
.
.
.
.
outgoingMessage
method
ColdFusion
Event
Gateway
Services
Listener
CFC
Event Gateway
Event Gateway
.
.
.
Listener
CFC
CFC
CFML
Page
Application
.
.
.
CFEvent
CFEvent
event
event
event
event
CFEvent
CFEvent
CFEvent
Message
CFEvent
Message
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...