Package sample
Class BlockingFlush
java.lang.Object
sample.BlockingFlush
public class BlockingFlush extends Object
The
Analytics class doesn't come with a blocking Analytics.flush() implementation
out of the box. It's trivial to build one using a Phaser that monitors requests and is
able to block until they're uploaded.
BlockingFlush blockingFlush = BlockingFlush.create();
Analytics analytics = Analytics.builder(writeKey)
.plugin(blockingFlush.plugin())
.build();
// Do some work.
analytics.flush(); // Trigger a flush.
blockingFlush.block(); // Block until the flush completes.
analytics.shutdown(); // Shut down after the flush is complete.
-
Method Summary
Modifier and Type Method Description voidblock()static BlockingFlushcreate()com.segment.analytics.Pluginplugin()
-
Method Details
-
create
-
plugin
public com.segment.analytics.Plugin plugin() -
block
public void block()
-