4

I need to implement database synchronisation in a Javaapplication and I started to use SymmetricDS which is a mature tool and allows to synchronise differents DBMS.

I played a little with SymmetricDS but I can't achieve my needs, so I have a few questions about this tool.

First I will expose the context of the application :
I developed a desktop application written in Java (JavaFX 2.0 + H2 database + Hibernate), I'm fairly new with Java but I managed to build a MVC architecture and finally finish a stand alone version of my application.
Now, I have to synchronize between multiple instances of the application installed on different computers.
I have a "master" MySQL database running on an external server, which also run SymmetricDS as "master" engine.
The applications uses H2 Database and ClientSymmetricEngine.
And I need to synchronize all the data between clients.

I managed to set up a more or less functional system using SymmetricDS but there are some sticking points:

  • Is there a way to simply implement the "last update wins" strategy instead of the "last sync wins" used by default ?

  • Is there a more complete documentation or step-by-step guide to embed SymmetricDS in an existing application ?

  • How I can extend symmetrics pull and push jobs without using Spring Framework (i need to freeze the application during synchronisation) ?

  • What happens if I purge by myself the tables :
    DATA DATA_EVENT OUTGOING_BATCH INCOMING_BATCH DATA_GAP NODE_HOST_STATS NODE_HOST_CHANNEL_STATS NODE_HOST_JOB_STATS after each a success push/pull ? This table grows quickly after a few minutes even if there is no changes to sync and this makes my application slow.

Thx for reading.
JBRTRND

jbrtrnd
  • 3,675
  • 5
  • 23
  • 41

1 Answers1

5

Is there a way to simply implement the "last update wins" strategy instead of the "last sync wins" used by default?

Yes, there is:

NEWER_WINS: Indicates that when a conflict is detected by USE_TIMESTAMP or USE_VERSION that the either the source or the target will win based on the which side has the newer timestamp or higher version number. The resolve_row_only column controls whether the entire batch should be ignore or just the row in conflict.

You'll have to use USE_TIMESTAMP or USE_VERSION conflict detection and then NEWER_WINS conflict resolution strategy.

Is there a more complete documentation or step-by-step guide to embed SymmetricDS in an existing application?

No, there is not. You'll have to figure it on your own or even better use the standalone server. Not only that you wont need to waste time integrating it within your app but future updates will be trivial. Just download the new version and replace the old.

How I can extend symmetrics pull and push jobs without using Spring Framework (i need to freeze the application during synchronisation)?

SymmetricDS is written using Spring so it will be quite hard extending using something else without a big rewrite. If you use the standalone server then there's no need to extend it avoiding Spring.

What happens if I purge by myself the tables: DATA DATA_EVENT OUTGOING_BATCH INCOMING_BATCH DATA_GAP NODE_HOST_STATS NODE_HOST_CHANNEL_STATS NODE_HOST_JOB_STATS after each a success push/pull ? This table grows quickly after a few minutes even if there is no changes to sync and this makes my application slow.

Don't purge on your own, just decrease the period of the purging job and decrease the period of survival of successfully synced code as explained here: http://www.symmetricds.org/doc/3.6/user-guide/html-single/user-guide.html#purge-job

Boris Pavlović
  • 58,387
  • 26
  • 115
  • 142
  • Thank you for answering. This make me take the way to develop my own synchronization module cause 1/ I don't want to use standalone server 2/ I don't want to use Spring ! :). – jbrtrnd Sep 11 '14 at 13:19
  • There are too many problems solved by SymmetricDS, I'm not sure I would suggest you to go through unless you're in the business of data synchronization. What's the problem with using a standalone server? – Boris Pavlović Sep 11 '14 at 13:25
  • The time spent to link the current version of application with the standalone server and the Spring immersion allows me to develop a lightweight and specific system and fully integrated in the application – jbrtrnd Sep 11 '14 at 13:48
  • Why do you need to link these two applications? I mean your application and the SymmetricDS standalone server – Boris Pavlović Sep 11 '14 at 14:24
  • First, to lock the application during pull and push (avoid loosing data) and maybe more in the future. – jbrtrnd Sep 11 '14 at 14:34
  • 1
    That's not needed if your application implements correctly transactional processing. What I mean by that? If in the middle of processing of something an exception occurs the whole previous changes should be rolled back. SymmetricDS synchronizes on a level of a batch, i.e. only fully committed data. Not partially. So, there's no need for your app and the SymmetricDS standalone server to know about each other. – Boris Pavlović Sep 11 '14 at 15:09
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/61103/discussion-between-boris-pavlovic-and-jbrtrnd). – Boris Pavlović Sep 12 '14 at 08:40
  • Hi! Also interested in your conversation. I've a requirement to run my app without any additional services, so I'm exploring the possibility of using SymmetricDS in embedded mode. @BorisPavlović, you think that's a bad idea? – Alexander Sep 09 '16 at 10:35
  • @Alexander it depends on many things. Is your application having a relational database? What's the platform that will host it? Mobile, desktop or virtual machine in the cloud? – Boris Pavlović Sep 09 '16 at 11:15
  • @BorisPavlović, I'm using postgres as DBMS and the application supposed to be hosted on Linux physical server. – Alexander Sep 09 '16 at 11:23
  • If possible go for the standalone server otherwise embedded is a viable option – Boris Pavlović Sep 09 '16 at 11:24
  • Got it, tnx! Too bad there is no comprehensive tutorial or sample – Alexander Sep 09 '16 at 12:39