After the public alpha was released on Monday on labs, there has been a lot of interest in using Apollo together with the Flex Data Services. The combination of Apollo and FDS allows you, for example, to easily push data to Apollo applications, or to seamlessly integrate Apollo applications with Java back-ends using Remoting or the Flex Data Management Services.
As an example of an FDS-powered Apollo application, I created an Apollo version of my real time market data application available as part of the Flex Test Drive for Java Developers.
The server-side remains unchanged… If you haven’t already done so, install the Flex Test Drive for Java Developers, and start the (fake) market data feed (http://localhost:8600/marketdata/startfeed.jsp).
In general, there are several strategies for configuring the FDS endpoints for your Apollo application:
- You can specify the endpoint URIs in services-config.xml. Note that when using Apollo, you can’t use tokens in the URI: you have to provide actual values for server name, context root, etc. For example, instead of:
- The strategy used in the trader desktop application is to programmatically create the channels at the client-side based on endpoint URIs provided by the user.
- You could also read the endpoint URIs from a runtime config file or runtime parameters.
To look at the connection logic of the application, open traderdesktop.mxml and look at the following code in the connect() method:
var rtmpChannel:RTMPChannel = new RTMPChannel("my-rtmp", rtmpEndpoint.text); var amfChannel:AMFChannel = new AMFChannel("my-polling-amf", amfEndpoint.text); amfChannel.pollingEnabled = true; amfChannel.pollingInterval = 2000; var channelSet:ChannelSet = new ChannelSet(); channelSet.addChannel(rtmpChannel); channelSet.addChannel(amfChannel);
This sample application is almost 100% identical to the browser version. I’ll continue to extend it by improving the UI, and using some specific Apollo APIs such as network detection and file IO to save data locally.