When a Flex application sends a message to a ColdFusion application, the Data Services 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:




Body of the message.


ID of the client that sent the message.


Correlation identifier of the message.


Flex destination of the message.


If the message contains any headers, the CFML structure that contains the header names as keys and values.


Timestamp of the message.

The incoming message data structure also includes the values of messageID and timeToLive from the Flex message.

Incoming message handling example

The following example places 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">

<!--- Create a structure to hold the message object sent from Flex--->
<cfset messagebody = event.data.body>

<!--- Populate the structure. --->
<cfset mailfrom="#messagebody.emailfrom#">
<cfset mailto="#messagebody.emailto#">
<cfset mailsubject="#messagebody.emailsubject#">
<cfset mailmessage ="#messagebody.emailmessage#">

<!--- Send e-mail with values from the structure. --->
<cfmail from="#mailfrom#"

If the Flex application sends the message in the header instead of in the body, you create and populate the structure, as the following example shows:

<cfset messageheader = StructNew()>
<cfset messageheader.sendto = event.data.headers.emailto>
<cfset messageheader.sentfrom = event.data.headers.emailfrom>
<cfset messageheader.subject = event.data.headers.emailsubject>
<cfset messageheader.mailmsg = event.data.headers.emailmessage>

<cfset mailfrom="#messageheader.sentfrom#">
<cfset mailto="#messageheader.sendto#">
<cfset mailsubject="#messageheader.subject#">
<cfset mailmessage ="#messageheader.mailmsg#">

New methods introduced in ColdFusion 9.0.1

The following new methods have been introduced in ColdFusion Messaging Gateway CFCs:

  • allowSend
  • allowSubscribe}}Both the methods take {{subtopic as the parameter. These methods help you place control over subscribing and sending data to a particular subtopic.
Note: To call these methods on their gateway CFC, specify the gateway id under the messaging destination in messaging-config.xml (Web_INF/Flex). By default, the value is *.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy