User Guide

Table Of Contents
1096 Chapter 45: Creating Custom Event Gateways
//log.error(e1);
}
}
// Close and release the serverSocket instance that gets requests from the
// network.
if (serverSocket != null) {
try
{
serverSocket.close();
}
catch (IOException e1)
{
}
//Release the serverSocket.
serverSocket = null;
}
// Shutdown succeeded; set the status variable.
status = STOPPED;
}
The restart method
In most cases, you implement the
restart method by calling the stop method and the start
method consecutively, but you might be able to optimize this process for some services. The
following code shows the SocketGateway class
restart method:
public void restart() {
stop();
start();
}
Responding to incoming messages
One or more listener threads respond to incoming messages (events). The threads must include
code to dispatch the messages to ColdFusion event gateway services, as follows:
1.
Create a CFEvent instance.
2.
Create a Map instance that contains the message and any other event gateway-specific
information, and pass it to the CFEvent
setData method.
3.
Call the CFEvent setOriginator method to specify the source of the message. (This is
required if the ColdFusion application will send 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 1088.)
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).