Source queries not started when asked for a sync

O Oesia Project 2 years 11 months ago
0 1 0

We have created two very simple (client and server) applications. Those app were generated by RhoStudio and RhoConnect respectively. Our goal is to undestand what the sync do, step by step.

We added 3 models in the client: Operator, Task and SystemOrigin. Then we added 3 sources in the server with the same name: Operator, Task and SystemOrigin. We added a debug line in every source function like this:

  def login
    log "Task::login"
    # TODO: Login to your data source here if necessary
  end

Then we did a simple test and we observed the following:

1. When we login in the client app the sync is started in the server (because of SyncEngine.dosync in login_callback function).

2. Server receives the sync signal and server does the three sources syncs. This is our trace:

[11:17:48 AM 2012-07-04] Use of the GET /api/application is deprecated. Use GET /api/application/query instead.
[11:17:49 AM 2012-07-04] Operator::initialize
[11:17:51 AM 2012-07-04] Operator::login
[11:17:51 AM 2012-07-04] Operator::query
[11:17:52 AM 2012-07-04] Operator::sync
[11:17:53 AM 2012-07-04] Operator::logoff
[11:18:01 AM 2012-07-04] Use of the GET /api/application is deprecated. Use GET /api/application/query instead.
[11:18:02 AM 2012-07-04] Task::initialize
[11:18:03 AM 2012-07-04] Task::login
[11:18:03 AM 2012-07-04] Task::query
[11:18:03 AM 2012-07-04] Task::sync
[11:18:04 AM 2012-07-04] Task::logoff
[11:18:12 AM 2012-07-04] Use of the GET /api/application is deprecated. Use GET /api/application/query instead.
[11:18:13 AM 2012-07-04] SystemOrigin::initialize
[11:18:15 AM 2012-07-04] SystemOrigin::login
[11:18:15 AM 2012-07-04] SystemOrigin::query
[11:18:16 AM 2012-07-04] SystemOrigin::sync
[11:18:17 AM 2012-07-04] SystemOrigin::logoff

3. This is correct, but... when we force a Sync, the server only executes the initialize function of sources:

[11:24:06 AM 2012-07-04] Use of the GET /api/application is deprecated. Use GET /api/application/query instead.
[11:24:07 AM 2012-07-04] Operator::initialize
[11:24:15 AM 2012-07-04] Use of the GET /api/application is deprecated. Use GET /api/application/query instead.
[11:24:17 AM 2012-07-04] Task::initialize
[11:24:24 AM 2012-07-04] Use of the GET /api/application is deprecated. Use GET /api/application/query instead.
[11:24:26 AM 2012-07-04] SystemOrigin::initialize

4. About 5 minutes later server sends a auto sync to client (because of the default  ":poll_interval: 300" of all sources).

We need to force a query function call when a sync is sent to server. This is because we need to obtain data from other source at that moment.

Our questions regarding this behaviour are the following:
- How can we change the query call from /api/application to /api/application/query in the client?
- How can we force a query call when a sync is received by the server?
- How can we obtain the client_id of the client in the query method of the source when an auto sync is sent by the server?

Thanks,
Oesía

Please register or login to post a reply

1 Replies

L Lars Burgess

- How can we change the query call from /api/application to /api/application/query in the client?
You don't need to worry about this, the client will be updated in a future version to use the new routes.
- How can we force a query call when a sync is received by the server?There is no way to "force" a query from the client, this is the exact purpose of the settings.yml's poll_interval option.  You can set it to a smaller value to trigger adapter queries more frequently.
- How can we obtain the client_id of the client in the query method of the source when an auto sync is sent by the server?Adapters are executed at the user level, so you can access the user who triggered the sync with the `current_user` object:

http://docs.rhomobile.com/rhoconnect/source-adapters#source-adapter-api

CONTACT
Can’t find what you’re looking for?