Sending a message using the SendGatewayMessage function

The SendGatewayMessage function has the following format:

SendGatewayMessage(gatewayID, messageStruct)

The CFEvent instance passed to the event gateway contains these two parameters in the GatewayID and Data fields; the remaining fields are empty.

The following example sends a message to a logging CFC, which logs information to a file. If the SendGatewayMessage function returns "OK", the example code displays a message. The code uses an instance of the asynchronous CFML event gateway named Asynch Logger. The props variable used in the messageStruct parameter has two entries, the destination file and the message to log.

<cfscript>
   status = "No";
   props = structNew();
   props.Message = "Replace me with a variable with data to log";
   status = SendGatewayMessage("Asynch Logger", props);
   if (status IS "OK") WriteOutput("Event Message ""#props.Message#"" has been sent.");
</cfscript>

Note: To see the code for the CFC that logs the information, see Using the CFML event gateway for asynchronous CFCs.


View comments in LiveDocs