Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 1337

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using External Resources
CFEvent instances returned from listener CFC
incoming message and other information. However, a gateway that could handle messages from the ColdFusion
function cannot rely on this information being available, so it is good practice to require that
SendGatewayMessage
all outgoing messages include the destination ID in the data Map.
The
method returns a String value. The CFML
outgoingMessage
to the ColdFusion application. Indicate the status of the message in the returned string. By convention, ColdFusion
event gateway
outgoingMessage
information (such as a message ID) to return.
Because event messages are asynchronous, a positive return normally does not indicate that the message was successful
delivered, only that the
outgoingMessage
possible to make the
outgoingMessage
provides two
outgoingMessage
The
Asynchronous mode
outgoingMessage
short message service center (SMSC) of the messaging provider.
The method does not return until the message is delivered to the SMSC, or an error occurs.
Synchronous mode
This way, an SMS application can get a message ID for later use, such as to compare with a message receipt.
Example outgoingMessage method
The following outgoingMessage method is like the version in the SocketGateway class. It does the following:
Gets the contents of a MESSAGE field of the Data Map returned by the CFEvent class
1
2
Gets the destination from an
Uses the socket server thread of the destination to write the message.
3
public String outgoingMessage(coldfusion.eventgateway.CFEvent cfmsg) {
String retcode="ok";
// Get the table of data returned from the event handler
Map data = cfmsg.getData();
String message = (String) data.get("MESSAGE");
// Find the right socket to write to from the socketRegistry hash table
// and call the writeoutput method of the socket thread.
// (Get the destination ID from the data map.)
if (data.get("outDestID") != null)
((SocketServerThread)socketRegistry.get(data.get("outDestID"))).
writeOutput(message);
else {
System.out.println("cannot send outgoing message. OriginatorID is not
available.");
retcode="failed";
}
return retcode;
}
Logging events and using log files
The
GatewayServices.getLogger
can use to log messages to a file in the ColdFusion logs directory. (You set this directory on the ColdFusion
Administrator Logging Settings page.) The method can take no parameter, or one parameter:
• The default
GatewayServices.getLogger
• Optionally, you can specify a log filename, without the .log extension or directory path.
onIncomingMessage
methods return "OK" if they do not encounter errors and do not have additional
method successfully handled the message. In some cases, however, it is
method at least partially synchronous. The SMS gateway, for example,
modes:
method returns when the message is queued internally for delivery to the
field in the data Map.
outDestID
method returns an instance of the coldfusion.eventgateway.Logger class that you
method uses the eventgateway.log file.
Last updated 1/20/2012
methods include the originator ID of the
function returns this value
sendGatewayMessage
getData
1332
method.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents