zk-and-rx"
Robertwenzel (talk | contribs) m (→Introduction) |
Robertwenzel (talk | contribs) m (→Introduction) |
||
Line 11: | Line 11: | ||
Since human supervisors are prone to errors too there should be multiple employees observing the same Robots simultaneously. | Since human supervisors are prone to errors too there should be multiple employees observing the same Robots simultaneously. | ||
− | Based on their current | + | Based on their current assignment and in order to preserve bandwidths it must be possible to track certain Robots near real-time (filtered by mood or position) without completely losing track of the overall situation, i.e. highlighted Robots have a faster update rate than others (100 ms vs. 1 sec). |
− | Employees may come and go as they like and connect/disconnect to the live data feed on demand. | + | Employees may come and go as they like and connect/disconnect to the live data feed on demand. |
However the Robots are constantly sending data at high frequency to your back-end process. | However the Robots are constantly sending data at high frequency to your back-end process. | ||
+ | Your challenge is to connect the UI to the stream of information reducing it based on the filter criteria and throttle the sheer amount of data to something the human eye and your network connection can handle. | ||
+ | |||
+ | = Architecture = | ||
+ | |||
+ | For the Robot event stream you choose rxjava and ZK for the frontend (disclaimer: I work for ZK and rxjava's reactive model fits well into ZK's MVVM design pattern, making an interesting combination worth talking about). | ||
Revision as of 08:40, 21 September 2017
Robert Wenzel, Engineer, Potix Corporation
September, 2017
ZK 8.5
Introduction
Assume you are working for a project on a Robot Farm (I think there could be worse projects). Unfortunately those Robots are a bit moody and unreliable sometimes - so of course there needs to be a supervisor sitting in his/her office chair and watching a screen to follow all the Robots movements.
Since human supervisors are prone to errors too there should be multiple employees observing the same Robots simultaneously.
Based on their current assignment and in order to preserve bandwidths it must be possible to track certain Robots near real-time (filtered by mood or position) without completely losing track of the overall situation, i.e. highlighted Robots have a faster update rate than others (100 ms vs. 1 sec).
Employees may come and go as they like and connect/disconnect to the live data feed on demand.
However the Robots are constantly sending data at high frequency to your back-end process. Your challenge is to connect the UI to the stream of information reducing it based on the filter criteria and throttle the sheer amount of data to something the human eye and your network connection can handle.
Architecture
For the Robot event stream you choose rxjava and ZK for the frontend (disclaimer: I work for ZK and rxjava's reactive model fits well into ZK's MVVM design pattern, making an interesting combination worth talking about).
The Backend (RX Observable)
Hot Observable
- constantly streams events, at short intervals (but unreliable maybe skipping information)
- allows multiple consumers
The UI (ZK MVVM application)
- render robots as divs + dynamic styles reacting on robot status (position, mood)
The Magic in the Middle
- filter the events (by selectable criteria)
- throttle UI updates (reducing the network load)
- buffer updates (100ms / 1000ms)
- avoid redundant updates
- batch update (in a single ZK execution)
Summary
Example Sources
The code examples are available on github in the zk-rxdemo repository
Running the Example
Clone the repo
git clone git@github.com:zkoss-demo/zk-rxdemo.git
The example war file can be built using the gradle-wrapper (on windows simply omit the prefix './'):
./gradlew war
Execute using jetty-runner (fastest):
./gradlew startJettyRunner
Execute using gretty:
./gradlew appRun
Then access the example http://localhost:8080/zk-rxdemo CHECK LINK
Comments
Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |