2 Replies Latest reply on Jul 2, 2012 1:30 PM by Matt Travis

    Sync Runtime error - Sync one source : Unknown Source

      I am trying to sync a single model and encountering a runtime error if I leave "enable :sync" disabled on my model.  I can get calls to go through if I enable sync for the Model, but then the Model tries to sync when the application initializes without required parameters.

       

      My goal is to reduce the initial sync time by having the user drill down into the application and sync Models on demand.  That way, only what they use gets loaded instead of filling up the database with information they may not ever use.

       

      As a result of having sync disabled on the Model, the application returns the message "Application has encountered an error and must close.", and when I look at the logs, I see the "Sync one source : Unknown Source" message.

       

      I have tried the following variations of running the sync with sync disabled on the Model:

       

      Model.sync(url_for(:action => :sync_callback), "", false, "query[param]=#{value}")
      SyncEngine.dosync_source(Model.get_source_id.to_i, false, "query[param]=#{value}")
      SyncEngine.dosync_source(Model.get_source_name, false, "query[param]=#{value}")
      

       

      Does "enable :sync" have to be enabled on the Model to use those calls?  If so, how do you prevent sync from running for a particular model when SyncEngine.do_sync is called?

        • Re: Sync Runtime error - Sync one source : Unknown Source

          You can disable background sync by setting poll interval to 0 in rhoconfig.txt:

           

          sync_poll_interval=0

           

           

           

          You can also change it dynamically:

           

          http://docs.rhomobile.com/rhodes/synchronization#syncengine-api

           

           

           

           

          set_pollinterval(interval)

           

           

          Update the SyncEngine poll interval. Setting this to 0 will disable polling-based sync. However, you may still use  <http://docs.rhomobile.com/rhoconnect/push> push-based-sync.

           

          SyncEngine.set_pollinterval(20)'

            #=> now polls every 20 seconds

           

           

           

           

           

          >>Does "enable :sync" have to be enabled on the Model to use those calls?

           

          YES

           

           

           

          >>If so, how do you prevent sync from running for a particular model when SyncEngine.do_sync is called?

           

          You can disable/enable sync of the models using:

           

          db = ::Rho::RHO.get_src_db(source_name)

           

          db.execute_sql(“UPDATE sources SET sync_type=? WHERE name=?”, )

          1 of 1 people found this helpful
            • Re: Sync Runtime error - Sync one source : Unknown Source

              I have already set the sync_poll_interval to 0.  That way, the application only syncs when the user first logs in or initializes the application.

               

              Querying the database and flipping sync on and off seems like a lot of unnecessary work so I will try to see what else I can come up with.

               

              I was hoping that I was missing a built in feature that would allow me to exclude syncing specific Models until I wanted to manually sync them.  I tried setting the poll interval associated with the Model to 0 in the Settings.yml file in my RhoConnect application (thinking that it would be the same as setting the sync_poll_interval to 0 for the application, but at the Model level), but that did not affect anything.  I also tried commenting out the polling in the same file.

               

              Message was edited by: Matt Travis  As clarification to the above, I realize that trying to change poll intervals would not logically affect SyncEngine.do_sync being run on the initial load.  I was just hoping that it would.  I guess I am looking for a property that removes the Model from the SyncEngine.do_sync Model list so I can individually call Model.do_sync.  Something like "enable :selfsync" (does not exist as far as I am aware) where if "enable :sync" does not exist and the "enable :selfsync" value exists, the sync option is still loaded for the Model, but it is not included in the SyncEngine.do_sync overall sync process.

               

              I think what I am going to do is just create a function that manually syncs a specific set of Models (top level) on the application load and then I can manually trigger the others later.  That way, SyncEngine.do_sync isn't calling all of the Models.