User Guide

20 Using the Flex Messaging Event Gateway
Sending outgoing message example
The following example from a CFM page creates a structure that contains the message. The
destination is the destination ID specified in the messaging-config.xml file for the instance
of the Flex Messaging event gateway to send the message to. The
body is the body of the
message. The
sendGatewyMessage CFML function sends the message to the instance of the
gateway.
<cfset success = StructNew()>
<cfset success.msg = "Email was sent at " & Now()>
<cfset success.Destination = "gateway1">
<cfset ret = SendGatewayMessage("Flex2CF2", success)>
Handling incoming messages
When a Flex application sends a message to a ColdFusion application, the Flex Messaging
event gateway sends a CFEvent structure to the
onIncomingMessage function of the
configured CFC, with the following information mapped to the data of the event:
The incoming message data structure also includes the values of
messageID and timeToLive
from the Flex message.
Incoming message handling example
The following example puts data that is contained in the body of the message from the Flex
application into a structure. It then uses the contents of the structure to generate an e-mail
message.
<cfcomponent displayname="SendEmail" hint="Handles incoming message from
Flex">
<cffunction name="onIncomingMessage" returntype="any">
<cfargument name="event" type="struct" required="true">
Name Contents
body Body of the message.
ClientID ID of the client that sent the message.
CorrelationID Correlation identifier of the message.
Destination Flex destination of the message.
Headers If the message contains any headers, the CFML structure that contains the
header names as keys and values.
Timestamp Timestamp of the message.