Wiki » History » Revision 30

Revision 29 (Tomek Dziemidowicz, 2019-07-04 09:00 PM) → Revision 30/43 (Tomek Dziemidowicz, 2019-07-04 09:03 PM)

h1. SQLite-sync documentation

*Owner* : AMPLIFIER sp. z o.o.
*Contact* : support (at)
*website* :


Welcome to the AMPLI-SYNC documentation!
We have language bindings in JavaScript, .NET C#, Java and Objective-C!

h2. AMPLI-SYNC concept

h3. Solution diagram


* Devices communicate with server using HTTP/HTTPS protocol.
* Proxy Load Balancer. If necessary, proxy can redirect request to another instance of SQLite-core.
* Authorization provider will generate token based on response from authorization provider.

h3. Proxy Balancer flowchart


h3. Authorization Provider flowchart


h2. REST API (server API)

h3. Protocol version

This document describes integration with the REST API 3.x protocol.

h3. Service description

There are two stages to processing a request:

* Device places an request.
* SQLite-sync server confirms the request has been processed successfully and sends confirmation with eventual conflict list that need to be resolved.

h3. Synchronization flowchart


h3. Request URL format

Sample REST API call:
** - adres of REST API service
*API3* - version of synchronization
*__method___* - method/action

h3. API methods

h4. *API3* - control method

*Method* : GET
*Path* : “/API3”
*Produces* : TEXT_HTML
*Description* : control method. Returns “API[v3] SQLite-Sync.COM is working correctly!” if web service is correctly configured.

h4. *InitializeSubscriber* - Reinitialize subscriber

*Method* : GET
*Path* : “/InitializeSubscriber/{subscriberUUID}”
*Produces* : TEXT_PLAIN
*Description* : Reinitialize subscriber, create empty schema on device, prepare master database for new subscriber.

Implementation examples:
* [[InitializeSubscriber Objective-C]]
* [[InitializeSubscriber .NET C#]]
* [[InitializeSubscriber JAVA]]
* [[InitializeSubscriber JavaScript]]

h4. *Sync* - gets changes for table

*Method* : GET
*Path* : /Sync/{subscriberUUID}/{tableName}
*Produces* : TEXT_PLAIN
*Description* : Get changed data.
*subscriberUUID* - identifier of subscriber. By default device unique ID is used. But we can place there any value (also #user.UUID)
*tableName* - name of table from database (without schema)
<pre><code class="xml">
<?xml version="1.0" encoding="utf-8"?>
<r a="1">
<c>2014-02-13 00:00:00</c>
<r a="2">
<c>Document 4</c>
<c>2014-04-23 13:44:48</c>
<records> - section contains records
<r a=”1”> - here starts record.
</r> - here record ends
Attribute “a” (action type)
1 - new record
2 - update for record

Implementation examples:
* [[Objective-C]]
* [[.NET C#]]
* [[JAVA]]
* [[JavaScript]]

h2. Conflict Resolution

h2. Update procedure

h2. Data filtering

h2. Installation

h3. Server Prerequisites

To make ampli-sync server work you need:
* Apache Tomcat 8.
* Java
* Linux/Windows environment.

h3. Manual

Steps needed to install AMPLI-SYNC manually on Ubuntu.

# Install Tomcat on Ubuntu:
# Create new user
sudo adduser amplisync
System will ask you for password for newly created user.
# Add user to group ‘tomcat’
sudo usermod -a -G tomcat amplisync
# Chang in web.xml path variable to
# Install new application in Tomcat. Start with switching to amplisync user.
su amplisync
# Create new folder /home/sqlitesync/demo
# Upload new service amplisync-demo to Tomcat. You can do that using Tomcat application manager, or you can put WAR file in Tomcat webapps folder. Name of your WAR file is app name in Tomcat environment. Remember to not place spaces and special chars in name of your WAR file.
# Restart Tomcat:
service tomcat restart
Now you can access your installation using link:
# Setup permissions:
chown -R sqlitesync:tomcat /home/amplisync/demo/

h3. Docker

h3. Configuring AMPLI-SYNC service

First you need to adjust website configuration file (web.xml), then you need to change main configuration file (
*Service configuration (web.xml)*
Go to your_webapps_folder/SqliteSync/WEB-INF/web.xml and open for edit. Navigate to section:
<pre><code class="xml">
change env-entry-value key and point to working dir where server will store log files, temporary files and configuration. Create manually a subfolder named config. Create a text file in folder config. The path should look like this:
*IMPORTANT* Restart service after changing web.xml. Make sure that Tomcat has read/write access to working dir.
Sample configurations for MySQL server
DB_ENGINE = mysql
DBURL = jdbc:mysql://server:3306/dbname?rewriteBatchedStatements=true
DBUSER = user
DBPASS = pass
DBDRIVER = com.mysql.cj.jdbc.Driver
DATE_FORMAT = yyyy-MM-dd HH:mm:ss
If you faced a timezone error after configuration in `` add at the end of connection string:
*Keys explanation*
*DB_ENGINE* - type of database engine. Available options:
* mysql
* mssql
* postgresql
* oracle

*LOG_LEVEL* - defain details level for log
> 4: TRACE, DEBUG, INFO, WARN; (default)
> 1: WARN;
> 0 - disable logs
*DATE_FORMAT* - set format of date
default format: yyyy-MM-dd HH:mm:ss
*HISTORY_DAYS* - How long files with sync data will be kept
default value: 7
When you use MySQL database DO NOT remove from the end of the connection string:

h2. Supported databases

AMPLI-SYNC supports those databases:

* Microsoft SQL Server (2005 and newer)
* Oracle
* PostgreSQL

h2. Samples
Go to top