Adobe ColdFusion 8

Sending messages

Your ColdFusion application sends a message to a Flex application by calling the ColdFusion SendGatewayMessage function. In messages sent from CFML, the following structure members are translated to the Flex message:

Name

Contents

destination

Destination of the message. This is required if it is not specified in the configuration file.

action

Required. The notification action that is being performed: create, delete, deleteID, refreshfill, or update.

item

Required when action="create" or action="delete". The record that was added or deleted.

identity

Required when action="deleteID". A structure that contains the identity properties (primary key) of the record that was deleted.

fillparameters

Optional. An array that contains the fills parameters that specify which fill operations to refresh.

newversion

Required when action="update". The record that was updated.

previousversion

Optional. The previous record, before the update. This is used for conflict resolution.

changes

Optional when action="update". A comma-delimited list or array of property names that were updated in the record. If you omit this, ColdFusion assumes that all properties changed. When you change a large number of records, you may find that specifying the property names improves performance.

Required when action="batch". An array of structures that contain the changes. You can batch multiple changes and send them in a single notification. The changes can be of different types, for example 5 updates, 1 delete, and 2 creates. Each event structure must contain an action.

Example

The following example creates a structure for each event type. It then creates a structure that contains the message. The message structure contains an array of event structures to send to Flex. The destination is the destination ID specified in the flex-services.xml file for the instance of the Data Management 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.

<cfscript>
// Create event
createEvent = StructNew();
createEvent.action = "create";
createEvent.item = newContact;

// Create update notification
updateEvent = StructNew();
updateEvent.action="update";
updateEvent.previousversion = oldContact;
updateEvent.newversion = updatedContact;

// Create delete notification
identity = StructNew();
identity["contactId"] = newId;
deleteEvent = StructNew();
deleteEvent.action = "deleteID";
deleteEvent.identity = identity;

// Send a batch notification
all = StructNew();
all.destination="cfcontact";
all.action="batch";
all.changes = ArrayNew(1);
all.changes[1] = createEvent;
all.changes[2] = updateEvent;
all.changes[3] = deleteEvent;
r = sendGatewayMessage("LCDS", all);
</cfscript>