Here i will explore the Flex data services . Flex data service is an object that you insert in MXML file. This object communicates with the business layer. This object is used to send and receive data from web services , Java remote objects and HTTP URL's.
Flex is a presentation layer technology and hence can not communicate with database directly. For this flex work with business layer to get the data.
The Flex data service architecture can be viewed as a combination of three services.
Flex Message service : Flex message service is a combination
of client side API and message service
running on server.
The managment of destinations is handled by message service and for publishing and subscribing to these destination , the client side API allow flex clients.
Message service is responsible for routing the message from a publisher to a destination where the subscriber are subscribed.
The steps for sending a message to destination:-
1: Create a producer to publish message to a specific destination.
<mx:Producer id = "pdoducer" destination ="Topic">
2: Now we need to create a message and publish it.
private function sendMessage():Void{
var message:AsyncMessage = new AsyncMessage();
message.body.topicID = topicID.text;
message.body.tMessage = topicMessage.text;
producer.send(message);
}
Now the steps for subsriber to subscribe a destination:-
1: <mx:Consumer id="consumer" destination ="Topic"
message = "mHandler(event)">
and the definition of mHandler
private function mHandler(event:MessageEvent){
var mBody:Object = event.message.body;
myTopic.text = mBody.topicID+":"mBody.tMessage;
}
The destination we were dealing above are configured at the server side in a XML configuration file( flex-message-service.xml ) . This xml files contains the information of destinations. The structure of the xml file is.
<destination id="Topic">
<properties>
<network>
<subscriber-timeout>0</subscriber-timeout>
</network>
<server>
<max-cache-size>1000</max-cache-size>
<message-time-to-live>0</message-time-to-live>
<durable>false</durable>
</server>
</properties>
<channels>
<channel ref="my-rtmp"/>
<channel ref="my-polling"/>
</channels>
</destination>
RPC Services:- A flex client can invoke methods of java object
deployed in application server. It can access the back-end data using the SOAP based webservices or using XML over HTTP . These three ways collectively called RPC services.
Flex Data Managment Service:- The client side API and data managment services running on appliaction server together form the flex data managment services.










