
1330
DEVELOPING
COLDFUSION 9 APPLICATIONS
Using External Resources
Las
t
upda
te
d 8/5/2010
3
Call the CFEvent
setOriginator
method to specify the source of the message. (This call is required if the
ColdFusion application sends a response.)
4
Call the CFEvent
setGateWayType
method to specify the event gateway type.
5
Set any other CFEvent fields where the default behavior is not appropriate; for example, call the
setCFCPath
method to replace the default listener CFC. (For information on default CFEvent fields, see “
CFEvent class
” on
page 1322.)
6
Call the
gatewayService.addEvent
method to dispatch the CFEvent instance to ColdFusion.
7
Handle cases where the event is not added to the event gateway service queue (the
addEvent
method returns False).
If your application sends any messages to multiple listener CFCs, the gateway must create and configure a CFEvent
instance and call the
gatewayService.addEvent
method to send the message to each separate listener CFC. The
setCFCListeners
method of the gateway must make the CFC paths available to the gateway for configuring the
CFEvent instances.
If your ColdFusion server carries a heavy event gateway message load, the ColdFusion event gateway services event
queue could reach the maximum value set in the ColdFusion Administrator. When the queue reaches the maximum,
the
gatewayService.addEvent
method returns False and fails. Your code can do any of the following:
•
Return a message to the sender to indicate that their message was not received.
•
Wait until the queue is available by periodically comparing the values returned by the GatewayService
getQueueSize
and
getMaxQueueSize
methods, and retry the
addEvent
method when the queue size is less than
the maximum.
•
Log the occurrence using the logger returned by the GatewayService
getLogger
method. (For more information,
see “
Logging events and using log files
” on page 1332.)
The SocketGateway class implements the listener using a java.net.ServerSocket class object and SocketServerThread
listener threads. (See the SocketGateway source for the SocketServerThread code.) When the listener thread gets a
message from the TCP/IP socket, it calls the following
processInput
method to dispatch the message to ColdFusion.
This method explicitly sets all required and optional CFEvent fields and sends the event to ColdFusion. If the
addEvent
call fails, it logs the error.
Note:
Much of the
processInput
method code supports multiple listener CFCs. A gateway that uses only a single listener
CFC, would require only the code in the latter part of this method.
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...