To begin working with messaging in a Flex application, you need to configure FDS to recognize the incoming messages. This configuration will be done in the messaging-config.xml file.
Here, you can see a sample messaging-config.xml file:
<?xml version="1.0" encoding="UTF-8"?> <service messageTypes="flex.messaging.messages.AsyncMessage"> <adapters> <adapter-definition default="true"/> <adapter-definition /> <adapter-definition /> </adapters> <destination > <adapter ref="cfgateway"/> <properties> <gatewayid>*</gatewayid> </properties> <channels> <channel ref="my-rtmp"/> <channel ref="my-polling-amf"/> </channels> </destination> </service>
Notice that the file has two main sections. First, adapters are defined that list the various types of system FDS to which Flex can send and receive messages. The three default adapters are listed here. If any custom adapters are written for the project, they also would be referenced in the adapters section.
Next, a destination is defined. The destination has an id, which is the name you will use in the MXML tags. (You'll see this in use in the next section.) This is followed by a reference to the proper adapter for the destination. In this example, the message is coming from a ColdFusion event gateway, so the cfgateway adapter is used. Any specific properties, which need to be set, are then added in the properties node. This example uses the gatewayid property of *, which enables the message to define a specific gateway, as opposed to restricting it to a specific event gateway from the server. Finally, the channels that this destination can use are specified. They reference channel-definition nodes in the services-config.xml file.