Synchronizing Data in Apollo using Flex Data Services


In my previous post, I provided an example of an Apollo application using the Flex Message Service. Since then, a number of people have asked for examples of Apollo applications accessing data using the Flex Data Management services. So here is a simple Contact Management application that demonstrates this integration.

Using the Data Services to work with data in Apollo offers several benefits. First, just like for traditional browser-based Flex apps, the Data Management Services automate the synchronization of data between the client and the middle-tier. In other words, you don’t have to flag/keep track of the changes made at the client-side, and then make corresponding RPC calls to send changes to the server: all that is managed automatically.

For this application, I actually used LiveCycle Data Services (the new name for Flex Data Services) 2.5 currently in beta 2, which offer additional benefits in the context of this application:

  • Using the new SQL assembler, you don’t have to write server-side components if you don’t want/need to: you just provide a series of SQL statements indicating how data should be retrieved, and how changes should be persisted in the database. The SQL assembler makes it extremely fast and easy to create applications that don’t require sophisticated persistence logic.
  • In 2.5, the DataService API provides methods (such as dataService.saveCache() / dataService.clearCache()) to save data locally and manipulate the local data store. You can also automatically synchronize the changes you made offline with the server. I ran into a bug in LCDS beta 2 that prevented me from implementing offline caching in this sample. The bug is fixed post beta 2 and I will share an updated version of the app when the bits become publicly available.

Installation instructions:

  1. Install LiveCycle Data Services 2.5 beta here
  2. Modify the flexdemosb database file to add the contact table: replace WEB-INF\db\flexdemodb\flexdemodb.script with this version.
  3. Open WEB-INF\flex\data-management-config.xml and add the following destination.
    <destination id="sql-contact">
    	<adapter ref="java-dao" />
    			<identity property="CONTACT_ID"/>
    			<paging enabled="false" pageSize="10" />
    			<throttle-inbound policy="ERROR" max-frequency="500"/>
    			<throttle-outbound policy="REPLACE" max-frequency="500"/>
    			    <!-- Modify the URL below with the actual location of the flexdemodb database on your system -->
       				<sql>SELECT * FROM CONTACT</sql>
    			  <id-query>CALL IDENTITY()</id-query> <!-- HSQLDB syntax to retrieve value of autoincremented column -->
    				<sql>SELECT count(*) FROM CONTACT</sql>
  4. Start the server
  5. Install contacts.air and run the application

NOTE: The application has been compiled assuming that an RTMP endpoint named my-rtmp is configured at rtmp://localhost:2037. If your server isn’t configured that way, you will have to recompile the application. You can also provide the endpoints at runtime. See my previous post for more information on defining a ChannelSet.

You can download the source code here.

  • Adam Adamczyk


    You have missed channel definition in your destination “sql-contact” settings. At least one channel must be defined. JRun trow following error

    03/31 21:56:58 user MessageBrokerServlet: **** MessageBrokerServlet failed to in
    itialize due to runtime exception: flex.messaging.config.ConfigurationException:
    Destination ‘sql-contact’ must specify at least one channel.

  • Not bad. But this is too simple. I wonder if Christopher can increase the complexity a little bit to to work with a small object graph. How about grouping the contacts, so we have another object called contact group which has a list of contacts and also factor out the address so that a contact is associated with an address (a shared object). Contacts are lazy loaded.

    This would make a decent practical real-world example and will save thousands of suffering hours by developers.


  • Samuel Flores

    Could you post the services-config.xml file you used for that application? I cannot compile the it and I’m not sure it’s the cause but I would like to look your configs. Thanks.

  • I just started my first SQLAssembler app.
    I managed one table. But how do you suggest to manage sub-table (for instance contacts friends).

    In the same DataService (destination)? Then same AS class “”. But how to delete reference to one friend? And how doing the binding in the data-management.xml?
    Or in another DataService (destination)?
    Or SQLAssembler is not suitable for this…

    Thanks Christophe…

  • Brian Cragin


    I have visited your site several times and have enjoyed your comments. My company is looking to bolster our web capability (RIAs) and are looking at adding a position that is versed in flex and other relavent programming languages. What type of skillsets would be appropriate or common among flex developers and at what salary do they usually run. I’m sure the answer depends on many variables which I have not described, but we aren’t looking for third-base, only the ballpark. Any information you can provide would be valuable.

  • I am about to start a multi-year project that will use Flex as the presentation layer technology. However I find it difficult to find any contacts at Adobe to help build the business case for using Flex. Please let me who I need to contact.


  • Nabeel Kamboh

    I was able to run the application with FDS successfully. I was also able to port the FDS code to run it on Tomcat.
    When I create a new apollo application in eclipse using the source code provided, I get an error in the service-config.xml. Turns out that channels now need to specify uri instead of url, also the default-channel needs to be included in each service not in the services block, also each service must have a messageTypes attribute.

    I made all of these changes and the app still works with the FDS. However, when I create a new Apollo application and run the apollo app using the eclipse builder, I get the following error:

    Error:[FaultEvent fault=[RPC Fault faultString=”Send failed” faultCode=”Client.Error.MessageSend” faultDetail=”Channel.Connect.Failed error undefined url:’rtmp://ewApp.swf:2037′”] messageId=”18583AC9-C52C-9DA6-5F4C-BF42E2CC45CC” type=”fault” bubbles=false cancelable=true eventPhase=2]

    I have the FDS server running and working with the installed air file provided but I get an error when creating a project and running it in eclipse. I am connecting to the same fds provider as the app and doing the same fill operation

    Please advise.

  • Hello! Good Site! Thanks you! dnprtvfcklg

  • Hello Christophe,

    First of all before I introduce myself I would like to compliment you on your amazing efforts in helping developers understand the true powers of Flex 2.0 and AIR. I am a big fan and found of your work on Adobe and your Blog. I have been working on my own in understanding the in-n-outs of Flex and how to create real powerful enterprise applications. I am strong follower of your work on Adobe and your own blog.

    I was trying your app the restaurant app. Finder posted on 15th March 2004. Currently on the Adobe web site. I have combined both the Java test drive with the restaurant app to create a working environment. Your work as helped me a great deal. I have been studying both of your apps, the restaurant search app (url) and the Java test drive. I am very grateful for your amazing efforts. In my learning process I found that your restaurant application is obviously written for the older version of Flex with Macromedia xmlns. I would like to repay your efforts in providing you with my update of the restaurant app to comply with Flex 2.0 in updating all the files including action scripts and functions even creating bind able custom events for the area search and review addition.

    I would be extremely honored to have my updated code reviewed by the top Flex evangelist world wide. Please find attached the following source files and the document that contains the change log on each exercise steps published on the web.

    Please let me know how I can email you my revised code? I was able to complete the restaurant app. But I did not have enough time to convert the restaurant admin app. I would like to complete it when the wife is not looking :p

  • Pingback: Synchronizing Data in AIR | Adobe AIR Tutorials()

  • Robert

    can you post the contacts.air for air runtime and not for apollo,please?

  • sathish


  • davis

    when i use SQLAssembler on mySQL, it can’t display the chinese or janpanes with utf8 encoding on Flex DataGrid. would you please do me a favor?

  • Hi Christophe,

    We’ve met a few weeks ago in Belgium concerning the usage of Flex Data Management Services for our data-driven application.

    This meeting was very useful to have an in-depth view on the most important features of FDMS.

    But I still have a few questions, otherwise it would be to perfect wright ;o))

    My questions:
    First what’s documented in flex2_devguide:
    ‘The Realtime Message Protocol (RTMP) channel maintains a connection between the client
    and the server, so the client does not have to poll the server. The Action Message Format
    (AMF) channel with polling enabled polls the server for new messages.’

    What’s confusing here is that FDMS works with a push-system to synchronize data instead of a poll-system – which is mentioned in the text above – to make sure that all client-app’s are working on the same up-to-date data.

    Could you elaborate if the usage of sprecific channel-types can interfere with the synchronization-mechanism of FDMS?

    Kind regards,

  • Pingback: Christophe Coenraets » Offline Synchronization using AIR and LiveCycle Data Services()

  • super! :)

  • Great ;)

  • Güzel bilgiler.

  • Pingback: Adobe LCDS « SrikanthCreative Mind’s Weblog()

  • when i use SQLAssembler on mySQL, it can’t display the chinese or janpanes with utf8 encoding on Flex DataGrid. would you please do me a favor?

  • Srikanth

    I am not able to download source code , if any one have source code please send me at

  • yah good post very nice For Admin..

  • can you post the contacts.air for air runtime and not for apollo,please?

  • very nice

  • Hey, I tried to e-mail you pertaining to this submit but aren?t in a position to attain you. Please e-mail me when get a second. Thanks.

  • hi do u know that, Adobe made a public preview release of AIR (then called Apollo) along with a software development kit (SDK) and extension for developing Apollo applications with the Flex framework, on March 19, 2007.

  • You have mentioned very interesting points! ps nice internet site. Juniors Sexy Stylish Bathroom Is The Specialty Swi

  • güzel çalışma olmuş arkadaşlar. sitemizin yeni yaptığı kampanyalar kaçmaz denilecek kadar sakın siz de kaçırmayın..!!!! adresimizden ulaşabilirsiniz…

  • Ameliyathane klimaları hijyenik olması şarttır hijyenik olmayan klimalar mikrop üreterek hastanın sağlığını tehdit eder.

  • Chillerlerinizi iyi ve tecrubeli ustalara teslim ediniz yoksa size ciddi maliyetler çıkartabilir. adresimizden iklimlendirme ile ilgili tüm çözüm ortağınızdır.

  • Klima servisinde dünya da hizmet veren firmamız sizlere de hizmet vermekten memnuniyet ve onur duyar.

  • klima servisi kampanyamız başlamıştır.

  • Thanks for this great article

  • Güzel yazınız için teşekkürler… Sanayi tipi buzdolabı imalatı ve servis hizmeti veren firmamızın sitesini incelemeniz dileğiyle….

  • gracias

  • thnx

  • fasstt foodd

  • You can visit our store for all our other models. Please contact us for you to design your own jersey. Please contact us for further information..

  • Değerli yazınız için teşekkür ederim. Sizinde sitemiz hakkında değerli yorumlarınızı beklerim.

  • ömer say

    Thanks a very useful article

  • ömer say
  • tezgah arası cam
  • elif dekor
  • Gergili Tavan
  • Enerama Çevre Teknolojileri Sa
  • Gergi tavan PVC malzeme Öztaş Yapı Dekorasyon firması tarafından patentli yüksek teknoloji ile üretilen, yangına, suya ve neme dayanıklı estetik, dekoratif, hijyenik ve göze hitap eden aydınlatma ve yapı elemanıdır. Germe tavan bakım gerektirmeyen ve geri dönüşüm özelliği olan çevreye duyarlı bir üründür. Gergi tavan Sistemleri ile iç ve dış mekanlarınıza benzersiz görünüm, estetik ve aydınlatma sağlayabilirsiniz.

    Gergi Tavanın Özellikleri & Uygulama Şekilleri
    Gergi tavan sistemleri yanmaması, su ve nemden etkilenmemesi ve uzun ömürlü olması sebebi ile genellikle iç mekanlarda dekoratif görsellik için kullanılmaktadır. Gergi tavan müşteri isteklerine göre Lake dokulu gergi tavan , Dijital baskılı & Transparan ışık geçiren, saten dokulu, mat dokulu gibi farklı uygulama şekilleri vardır. Mekanlarınıza en uygun gergi tavan ürünü için bizimle iletişime geçebilirsiniz.

    Gergi Tavan Kullanım Alanları
    Konutlar ve tüm odaları, Okullar, Apartman girişleri,
    Düğün salonları, Oteller, Villalar ve Hava alanları
    Kuaförler, Güzellik salonları ve Spa Merkezleri
    Alışveriş merkezleri ve Mağazalar
    Hastaneler, Diş Klinikleri, Ofis ve Bürolar
    Sanat Galerileri, Teşhir Alanları, Fuar ve Showromlar
    Sinemalar ve Restoranlar vb…

  • İstanbulda bulunan Öztaş Yapı Dekorasyon Mutfak tezgah arası cam panel sistemlerinde oldukça başarılı bir ivme kazanmıştır. Metre tül fiyatları konusunda oldukça cazip fırsatlar sunan tezgah arası cam uygulamaları istediğiniz görsel ve modele göre çalışma sağlanmaktadır.

    İster tek renk tezgah arası cam ister 3d tezgah arası cam panel uygulmasını yada mutfak tezgah arası cam kaplama uygulamalarını tercih edebilirsiniz. Birbirinden güzel modeller profesyosnel ustalarımızın ellerinde çok uygun fiyatlara mükemmel tasarımlara dönüşmektedir. Sizlerde yaşam alanlarınızı bu güzel malzeme ile bütünleştirmek istiyosanız ÖZTAŞ Mutfak tezgah arası cam panel sistemleriyle tanışınız.

    3D Tezgah Arası Mutfak Uygulaması, farklılık yaratmak isteyenler, vaktinin büyük bir kısmını mutfaklarda geçiren bayanların yüzünü güldürecek, Tezgah Arası 3d Cam uygulaması birbirinden dekoratif desenleri ile iddia ediyoruz aklınızı başınızdan alacak. Mutfakta geçtiğimiz zamanı keyfe dönüştürecek. Milyonlarca desen arasından istediğinizi beğenip, kısa zaman içerisinde oldukça ekonomik fiyatlatlara, öztaş yapı dekorasyon kalitesiyle sipariş verebilirsiniz.
    Türkiye’de ve özellikle İstanbul’da en kaliteli 3d mutfak tezgah arası cam işlemleri firmamız tarafından gerçekleştirilmektedir.

  • altav yapı

    İstanbulda bulunan firmamız baklava ayna, mutfak tezgah arası 3d cam panel ve gergi tavan işi yapmaktadır.

  • altav yapı

    Baklava ayna, kare kare dilimli olacak şekilde kesilerek yan yana düzenli ve tasarımsal olarak dizilen, duvara kaplama yapılarak uygulaması yapılan flotal aynalardır. Geniş ve ferah ortamlar ortaya çıkarmak, rahat yaşam alanları içerisinde oturmak, çalışmak için zevkinize en uygun aynalardır.

  • Hilal

    iphone tamir hizmetleri olarak teşekkür ederiz.

  • Hilal olarak teşekkür ederim.