User Guide

Table Of Contents
1094 Chapter 45: Creating Custom Event Gateways
ColdFusion MX calls the setCFCListeners method with the CFC or CFCs that are specified in
the ColdFusion MX Administrator when it starts a gateway. ColdFusion MX also calls the
method in a running event gateway when the configuration information changes, so the method
must be written to handle such changes. The
setCFCListeners method must save the listener
information so that the gateway code that dispatches incoming messages to gateway services can
use the listener CFCs in
setCFCPath methods.
ColdFusion MX calls the
setGatewayID method when it starts a gateway. The getGatewayID
method must return the value set by this method.
ColdFusion MX calls the
getHelper method when an application calls the CFML
GetGatewayHelper function.
The following code shows how the SocketGateway class defines these methods. To create a new
gateway, modify the
getHelper definition to return the correct class, or to return null if there is
no gateway helper class. Most gateways do not need to change the other method definitions.
public void setCFCListeners(String[] listeners) {
this.listeners = listeners;
}
public GatewayHelper getHelper() {
// SocketHelper class implements the GatewayHelper interface.
return new SocketHelper();
}
public void setGatewayID(String id) {
gatewayID = id;
}
public String getGatewayID() {
return gatewayID;
}
public int getStatus() {
return status;
}
Starting, stopping, and restarting the event gateway
Because an event gateway uses at least one listener thread, it must have
start, stop, and restart
methods to control the threads. These methods must also maintain the status variable that the
Gateway class
getStatus method checks, and change its value among STARTING, RUNNING,
STOPPING, STOPPED, and FAILED, as appropriate.
The start method
The
start method initializes the event gateway. It starts one or more listener threads that
monitor the gateway’s event source and respond to any messages it receives from the source.
The
start method should return within a time-out period that you can configure for each event
gateway type in the ColdFusion MX Administrator. If it does not, the ColdFusion MX
Administrator has a Kill on Startup Timeout option for each gateway type. If you select the
option, and a time-out occurs, the ColdFusion starter thread calls an interrupt on the gateway
thread to try to kill it, and then exits.