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.

Download the client application here. (You can download the source code here).

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:

  1. 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:
  2. http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling

    use:
    http://localhost:8600/messagebroker/amfpolling

  3. 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.
  4. 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);
  5. You could also read the endpoint URIs from a runtime config file or runtime parameters.

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.


            


作者:gdgzboy@牛C网
地址:http://www.niuc.net/post/273/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!



Tags: ,
评论(0) | 引用(0) | 阅读(281)
发表评论
昵称 [注册]
密码 游客无需密码
网址
电邮
打开HTML 打开UBB 打开表情 隐藏 记住我