Posts tagged "Data Services"

Specifying channel fallback for Flex applications using Data Services

Note: Edited 22 November 2001 to add symptoms that fallback to RTMPT can cause and how to disable RTMPT.

Data Services servers that have a high volume of messaging connections can have a problem in which all available sockets or threads are used. Another point of issue they can have, too, are large worker threads that seem to linger long after they are no longer being used. Sometimes the amount of memory consumed by these threads is great enough that the developer begins to suspect there is a memory leak. It is a particular problem if the number of client application that cannot connect to the server via the conventional RTMP port is large.

The most effective protocol to use for messaging within Data Services is RTMPS. Not all firewalls allow the passing of RTMPS traffic. Messaging between Data Services and Flex can use several protocols, including HTTP streaming. The process of the Flex client using alternative protocols when the preferred do not work is called fallback. Which protocols are preferred and in what order they are attempted during fallback can be configured.

Fallback between Data Services and Flash is mostly programmed within Flash. The server.xml and messaging.xml configuration files define a contract between Flex and the server. Flex reads the configuration files at runtime and follows those specification when connecting to the Data Services server. The Data Services server uses the configuration file to know which endpoints it needs to make available for Flex to use.

Say a developer wants a fallback from RTMPS to the HTTP Streaming. And they need the fallback to be secure. Within the services-config.xml file the configuration for the secure HTTP streaming needs to be added. If the developer is sending XML back and forth they can use HTTP secure streaming. For passing AMF data the developer can use the AMF version of the HTTP secure streaming.

<channel-definition id="my-streaming-amf">
     <endpoint
         url="http://{server.name}:{server.port}/{context.root}/messagebroker/securestreamingamf"
         class="flex.messaging.endpoints.SecureStreamingAMFEndpoint"/>
     <server ref="secure-nio-streaming-amf-service"/>
</channel-definition>

 

The endpoint, secure-nio-streaming-amf-service, needs to be defined within the configuration like in the same way are for RTMPS.

The fallback order is specified in the messaging-config.xml. So the secure HTTP streaming endpoint needs to be added:

<channels>
     <channel ref="my-rtmps" />
     <channel ref="my-rtmp" />
     <channel ref="my-streaming-amf" />
</channels>

 

The configurations on the server make the fallback endpoints available and gives the Flex compiler a way of knowing the endpoints to use for fallback. Flex does not make a query to the server at run time for the preference order of endpoints. This information needs to be compiled into the client or handled within the ActionScript on the client layer. I am guessing this is done for security reasons. If a client obtained endpoint information at runtime it is possible for someone to point the client to their own servers and hijack your traffic.

One last step must be completed to keep RTMPT from being used. There is a setting to disable it: block-rtmpt-polling-clients. Adding this property to the RTMP channel will disable it.

<channel-definition id="serverRtmp" class="mx.messaging.channels.RTMPChannel">
    <endpoint uri="rtmp://localhost:2037/rtmp" class="flex.messaging.endpoints.RTMPEndpoint"/>
    <server ref="nioserver"/>
    <properties>
        <block-rtmpt-polling-clients>true</block-rtmpt-polling-clients>
    </properties>
</channel-definition>

 

How to Set Fallback on the Client

There’s more than one way to set up fallback within your client. Your Consumer class instances have a channelSet property that contains the list of channels to use in order of preference. This information needs to populated within your client. This can be done with just configuration. You can also use MXML and ActionScript to set the fallback.

Specifying Fallback Through Configuration Only

There is a compiler tag, -services, that can be used with the MXML compiler of the Flex SDK. The tag -services should be set to the path of your services-config.xml. When you do this, your MXML will be compiled with the server-specific information. When a new instance of Consumer is created it will have its values already populated with the values you specified in your configuration. If you are compiling an ActionScript-only application or component this value will not be pre-set. I am supposing you at least have a top-level MXML application file.

Specifying Fallback Through MXML

A Consumer instance can be created using MXML.

<Consumer id="msging" destination="messagingDestination">
     <mx:channelSet>
          <mx:ChannelSet>
               <mx:channels>
                    <mx:SecureStreamingAMFChannel
                         id="secureStreaming"
                         uri="http://myserver:2000/myapp/messagebroker/secureAMF"/>
               </mx:channels>
          </mx:ChannelSet>
       </mx:channelSet>
</Consumer>

 

Specifying Fallback Within ActionScript

The following example shows ActionScript code that is equivalent to the MXML code in the previous example:

private function run():void
{
    consumer = new Consumer();
    var cs:ChannelSet = new ChannelSet();
    cs.addChannel(
            new SecureStreamingAMFChannel (
            "secureStreaming",
            "http://myserver:2000/eqa/messagebroker/secureAMF")
    );
    consumer.destination = "secureStreamingAMF";
    consumer.channelSet = cs;
}

 

Detecting the Type of Channel Being Used By a Consumer

The same channelSet property of a Consumer instance that can be used to set the fallback channels can be used to detect the current channel type. ChannelSet has a the property, currentChannel. Each type of channel has its own class. Those classes can be found in the documentation for the … package. Each channel also has a protocol property. If the channel is RTMP or RTMPS, the value of protocol will be the string, “rtmp.” If the channel is RTMPT, the protocol will be “rtmpt.” For all non-secure HTTP channels the protocol is “http.” For all secure HTTP channels the protocol is “https.”

Documentation

Real-Time Messaging with LiveCycle Data Services ES
http://blogs.adobe.com/flexdoc/2007/07/realtime_messaging_with_livecy_1.html

This is very good documentation about messaging and includes information about fallback. A lot of this may be too basic for you, but there is enough here that there may be some details that will help you out.

About channels and endpoints

http://help.adobe.com/en_US/LiveCycleDataServicesES/3.1/Developing/WSc3ff6d0ea77859461172e0811f00f6e876-7fecUpdate.html

 

Deconstructing Experience Services: Data Services

It began as Flex Data Services. Then the software became LiveCycle Data Services. Now it is just called Data Services. Data Services has been made a component of ADEP Experience Services. Besides a name change from LiveCycle, it can be deployed differently. No longer exclusively tied to J2EE servers, it is now available as an OSGi bundle. The Java EE application server version continues and continues to be supported. While basically the same, there are some slight differences. The location of configuration files is slightly different. In addition, there are some differences in the way Java classes need to be deployed to work with Data Services. Lin has some very good blog posts about this: [How to Create a Data Services application for the Experience Server that returns data and How to create class/jar files for data service project without using maven].

Once logged onto the Experience Services as an admin there is a dashboard with all sorts of interesting links. There are five you need to concern needed to get started with Data Services. The right side contains three: CRXDE Lite, Packages, and Package Share. On the left you need to know about two, Getting Started and OSGi Console.

Experience Services admin screen

Experience Services admin screen

CRXDE Lite is an application to browse the JCR object database. Where in the Java EE version of Data Services you would put configuration files within folders, the Data Services server is entirely self-contained within this database. Configuration files are within the hierarchy of the database. The Packages link lets you see which packages you have installed and deploy or undeploy packages. The Package Share link lets you install more. Package Share leads to a library of available packages that can be installed.

The Getting Started link points to an area with good documentation on how to use Experience Services and contains Data Services examples. After following that link you will see a section, Application Use Case Samples, with the example applications. The first example, called Data Integration, shows how to use Data Services within its new framework. Follow the link, Developer tutorial, that is in the right side of that example’s box.

There is one last thing that needs to be done before developing with this server. On any screen click the Adobe Digital Enterprise Platform logo in the top left of the screen – this will take you back to the main screen. Press the OSGi Console link in the left section. This is where configurations are set. To develop with Flex and integrate it with the Experience Services the default setting for RDS needs to be changed. The Configuration tab should be selected at the top. Select Adobe Data Services from the list. You will see its configurations. Make Enable RDS selected and the environment is ready to work with for development. Disable RDS in production environments for security.

Data Services gives the Flex front-end of an application access to the middle-tier services on a server. It has a very efficient data transport protocol for Flex. It allows real-time messaging protocols that give the developer the ability to push and pull data from Flex. Data Services can act as a relay and be a proxy host for other services. It provides data management that works with Flex, sending only the data need for display. Someone gave me a short summary of Data Services that is more complete:

Data Services provides remoting (RPC), messaging (publish/subscribe and push) and data management capabilities for the creation of rich Internet application (RIA’s) as well as multi-screen, mobile or occasionally-connected applications. Data Services also provides a highly productive set of model-driven development capabilities which enable developers to focus on application and business logic and includes a wide variety of back-office data connectivity options including connectivity to server-side Java code, SAP, RDBMS’s, Hibernate, JMS and other server-side systems and technologies.

There’s quite a bit of information in that description and it would be interesting to discuss all of its capabilities separately. Data Services is a great tool in a developer’s kit.

[Edited 10/20/2011: I said the Data Services “is deployed totally differently. No longer tied to J2EE servers….” I should have pointed out that it is not exclusively an OSGi bundle. It is continuing to be available for Java EE application servers, with the next version being 4.6. This version is available for public preview on Adobe Labs. I also added references to some very good links from Lin’s blog about creating Data Services applications for the Experience Server. I added a short summary of Data Services I got from someone else.]

Resources:
First step with Experience Services trial: how to deploy
Data Integration – ADEP Samples