opendolphin to keep 3000 objects syncronized to the clients

94 Views Asked by At

I have an JavaFX standalone application in a server PC doing the following:

Take data from some serial devices (rs232) each 200ms and save that data in a postgresql database. That size of the data is up to 2500 objects with 15 fields (2500 rows with 15 columns in database)

Also, i have others Javafx applications (clients) in the Local Area Network that take that data from the server database each 500 ms, and display them in a JavaFX GUI.

My question is: Can i use Open Dolphin to keep all those objects synchronized in all the clients? (taking in account the sampling time requierement and the amount of data).

I have been reading about OpenDolphin, but the examples that i saw are with Strings synchronization, without time pressure.

PD: If not, which one technique would be?

Thanks

1

There are 1 best solutions below

2
On

This solution is directly extracted from a class of mine and you gave me an idea, so I'll just implement it; the class is here.

What I intend to do following your question is to replace the ExecutorService which is currently there by a ScheduledExecutorService and implement the method below; note that the @OnBackgroundThread and @OnUiThread are "just" regular, @Documented annotations which I use:

public <T> void computeFixedDelay(
    @OnBackgroundThread final Supplier<? extends T> supplier,
    @OnUiThread final Consumer<? super T> consumer,
    final long quantity, final TimeUnit unit)
{
    backgroundExecutor.scheduleWithFixedDelay(() -> {
        final T value = supplier.get();
        frontendExecutor.execute(() -> consumer.accept(t));
    }, 0L, quantity, unit);
}

Feel free to copy the task and implement the suggestion then add this method. You will then be able to do this in your JavaFX clients by initializing an instance of this class (pass Platform::runLater as the second argument).

Below it is assumed that:

  • db::task is what gets the data from the database;
  • ui::update takes that data and updates the GUI.

You can then do:

taskRunner.computeFixedDelay(db::task, ui::update, 500L, TimeUnit.MILLISECONDS);