Interface ISmintIoSynchronization
- All Known Implementing Classes:
SmintIoSynchronization
Two kinds of events triggering synchronization: scheduled + on demand pusher
Synchronization of purchased assets are performed on a regular/scheduled basis in the background. A timer is used to start this task every hour. Additional, synchronization can also started on demand, as soon as any new asset has been bought on Smint.io. Hence the scheduled process does not need to run every minute but can be scheduled utilizing a wider interval. In order to speed-up on-demand sync, the structured meta data usually is not synchronized at this step. It can be assumed that syncing meta data in the scheduled process only is sufficient. So an initial synchronization is required, usually performed during development time of any implementing instance.
- scheduled sync — automatic synchronization task in the background synchronizing all data
- on demand pusher — manually/programmatically started task to synchronize binary assets only. Such an on-demand event will be triggered by the Smint.io platform utilizing channel-services of Pusher.com
Registering with Pusher.com
To receive notifications for on-demand synchronization in case of any purchase, the synchronization job registered
itself to the channel API of
Pusher.com. In general, a web socket is opened to something like
https://ws-*.pusher.com
. The web socket is used to exchange notification. In order to make that work, the
open socket must be kept available and a reference to it maintained. Hence the subscription to the channel is started
along the scheduled job in order to ensure a reference to ISmintIoSynchronization
is available with its
internal reference to the channel socket.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstart()
Start a scheduled synchronization, register with channel listener and store a reference with the scheduler.stop()
Stop the scheduled synchronization process.Perform a synchronization of all meta data and assets.triggerSync
(boolean syncWithMetaData) Perform a synchronization of all meta data and assets.
-
Method Details
-
start
ISmintIoSynchronization start()Start a scheduled synchronization, register with channel listener and store a reference with the scheduler.The scheduling is maintained by the implementing class. It will schedule only one process, no matter how often this method is executed. Only a new schedule is created but no sync process started.
Along the scheduled job, the job is registered with the the channel API of Pusher.com to receive push notification in case of any purchase.
Beware: a reference to this instance is stored with the scheduler. So as long as there is an active schedule garbage collection won't apply.
The first job will be started immediately upon calling this method.
- Returns:
this
in order to support Fluent Interface paradigm.
-
stop
ISmintIoSynchronization stop()Stop the scheduled synchronization process.Only the schedule is stopped (removed) and the channel API of Pusher.com is disconnected. Any currently running synchronization process is not terminated.
- Returns:
this
in order to support Fluent Interface paradigm.
-
triggerSync
Perform a synchronization of all meta data and assets.A new synchronization task will be executed. In case such a task is already being executed, a new one will be put into the waiting queue. If there already is a job waiting for execution, no new job is being scheduled but the returned
Future
is going to wait for the termination of the already queued task.- Parameters:
syncWithMetaData
- iftrue
the sync job will synchronize the meta data too. Iffalse
, only assets are synchronized.- Returns:
- a
Future
that will returnnull
in itsFuture.get()
function, once synchronization job has finished.
-
triggerSync
Perform a synchronization of all meta data and assets.calls
triggerSync(boolean)
with parametertrue
.- Returns:
- a
Future
that will returnnull
in itsFuture.get()
function, once synchronization job has finished.
-