9 Replies Latest reply on Jan 31, 2013 6:38 PM by Earl Roberts

    RhoConnect Push via MySQL source adapter

      Hi.

      I am trying to modify the webinar code for "Dec 12, 2012 - RhoConnect Push" to use MySQL database installed on my local PC (as per webinar "Oct 17, 2012 - Direct Database Connectivity Using RhoConnect").

      What I did so far was to start with the RhoConnect Push webinar code and generated a source adapter called "product.rb".

      I then modified the store-rhoconnect/sources/product.rb using the code from the webinar

      "Oct 17, 2012 - Direct Database Connectivity Using RhoConnect" as a template.

       

      This resulted in partial success whereby the new app I created (lets call it RhoConnectPushMySQL) does in fact connect correctly to the MySQL database.

      However, it only displays the Product table data that already exists within the MySQL database.

      If I attempt to create a new Product row and then do a "sync" the new row is not saved to the MySQL database.

      Instead, only the data within the MySQL database is displayed.

       

      Any advice on what I'm doing wrong or missing ?

      Perhaps I need to modify rhostore-master/config/initializers/rhoconnect.rb and change my "config.app_endpoint" to point to MySQL ?

       

      Details of my environment:

      Windows XP Personal Version 2002 SP3

        RhoStudio    2.0.0.201211162257 

      MySQL 5.2.44 CE

       

      Many Thanks !!

        • Re: RhoConnect Push via MySQL source adapter

          Just for the record I have MotorolaRhoMobileSuite2.2.1.12 installed (not 2.0.0.201211162257 which is shown by Help->About and is incorrect).

            • Re: RhoConnect Push via MySQL source adapter
              Peter Arcuri

              Please be aware of a setting that may be the cause of not sync'ing after the initial sync. The poll_interval default value is set to 5 minutes (300 seconds). That means this value must elapse before sync'ing again. You can decrease this value or disable it entirely by replacing the value to 0. This setting can be found in the setting.yml file within your rhoconnect app.

               

              Settings.yml.png

                • Re: RhoConnect Push via MySQL source adapter

                  I have modified poll_interval to 0 and this does not resolve the issue.

                   

                  Please note that when I do a manual sync by clicking on the "Sync" button on my simulator the MySql local DB changes are refreshed on my simulator.

                  However, if I created any new products on the simulator they are lost (i.e NOT synced to the DB).

                  If I use the MySQL utility to create a new product row in the DB then when I "Sync" on the simulator the new product row appears in the simulator correctly.

                   

                  So in summary, if I create a new product on the client simulator screen then they are not saved to the DB are are lost when I click on "sync".

                    • Re: RhoConnect Push via MySQL source adapter
                      Peter Arcuri

                      When you say "create any new products on the simulator they are lost" do they show at all in your app's UI? Can you create products with your client app?

                       

                      If you can create and see new records and then the sync doesn't  push new records to the back-end DB, then it sounds as the create method from your source adopter isn't doing it's job. Is your source adaptor referencing DB attribute names? if so, check that they're correct.

                       

                      Also. I would suggest checking and ensuring the Product model name from your RhoElements app is identical (case sensative) to the name of the source adaptor of your RhoConnect app.

                      • Re: RhoConnect Push via MySQL source adapter

                        Any new products created on the simulator do indeed show up on the app's UI correctly.

                        However, they are "lost" (or disappear) from the app's UI only AFTER I press the "sync" button on the app's UI.

                         

                        That is, after the "sync" button is pressed the data from the local DB is refreshed on the app's UI (i.e the new rows created on the app's UI are NOT saved to the local MySQL DB).

                         

                        Thanks for pointing out the case sensitivity of the "product model name". This was one of my initial problems.

                        Although I still don't understand why the URL "http://localhost:3000/products/" is NOT "http://localhost:3000/product/" (singular instead of plural).

                        Nowhere in the project can I see the plural form used ?

                         

                        I only see "product" or "Product"

                          • Re: RhoConnect Push via MySQL source adapter
                            Peter Arcuri

                            Is the backend app based on Rails or .NET? If Rails then the http://localhost:3000/products probably comes from the schema file, specfically in the "schema.rb" file located in the "db" folder of your rails app.

                             

                            The problem I see here is the mix of two sync methods - Source adopter and Push. Although coexistance is feasable, i find it could be redundant in some instances, which may reequires some fine tunning. If you have RhoConnect Push working you'll see that create/update/delete transactions do get sync'd regardless where they're initiated. In other words, with your setup from webinar of Dec 12 you could sync bi-directional including addition records from the client. That said, not only can you auto sync records updates from the back-end system you can also sync change initiated by a manual sync from the device.

                             

                            Note, in order for Push to work you'll need to run your app from a device with the push notification services installed and running. 

                              • Re: RhoConnect Push via MySQL source adapter

                                > Is the backend app based on Rails or .NET?

                                 

                                Remember my project code is based on the webinar example code (as per "Dec 12, 2012 - RhoConnect Push").

                                Therefore from my limited understanding (I'm a newbie) the backend app is based on Rails.

                                 

                                Peter your suggestion to look at schema.rb has put me on the correct track to debug and SOLVE the issue :

                                What I discovered was that I had a syntax error in SQL Insert statement (within the source adapter).

                                The rhoconnect error log showed "SourceAdapter raised create exception: Too many SQL parameters".

                                My incorrect SQL that caused this error was 'INSERT into products (name, brand, price, quantity, sku) VALUES (?,?)'

                                The correct SQL should be 'INSERT into products (name, brand, price, quantity, sku) VALUES (?,?,?,?,?)'

                                 

                                After fixing this everything now works correctly and I successfully have RhoConnect Push working via a MySQL source adapter.

                                 

                                Thank you very much for taking the time to assist in resolving this problem !!

                      • Re: RhoConnect Push via MySQL source adapter

                        Did you set the `:push_notify:` field in your settings.yml as described in the webinar?  Otherwise no automatic pushes will be sent.