Skip navigation links

Package com.amazonaws.mobileconnectors.kinesis.kinesisrecorder

Primary classes for interacting with the Kinesis connector for offline storage of records, and improved performance when working with to Amazon Kinesis.

See: Description

Package com.amazonaws.mobileconnectors.kinesis.kinesisrecorder Description

Primary classes for interacting with the Kinesis connector for offline storage of records, and improved performance when working with to Amazon Kinesis.

KinesisRecorder and KinesisFirehoseRecorder are high level clients for Amazon Kinesis. They offer storing records on the users Android device before sending to the server. This allows developers to retain requests when the device is offline. It can also increase performance and battery efficiency since the wi-fi or cell network does not need to be woken up as frequently.

KinesisRecorder and KinesisFirehoseRecorder are very similar. The main difference is the destination. KinesisRecorder sends data to Amazon Kinesis Streams and developer needs to write applications to process streamed data from the service. Whereas the latter sends data to Amazon Kinesis Firehose which is a fully managed service for delivering real-time streaming data to destinations such as Amazon Simple Storage Service (Amazon S3) and Amazon Redshift.

The following is an example of KinesisFirehoseRecorder.

 // working directory for the recorder
 File directory = context.getCachedDir();
 // AWS Firehose region
 Regions region = Regions.US_WEST_2;
 // initialize a credentials provider
 AWSCredentialsProvider provider = new CognitoCachingCredentialsProvider(
         context,
         "identityPoolId",
         Regions.US_EAST_1);
 KinesisFirehoseRecorder firehoseRecorder = new KinesisFirehoseRecorder(
         directory, region, provider);
 // save some strings
 String streamName = "my_stream"; // Firehose delivery stream name
 firehoseRecorder.saveRecord("Hello world!\n", streamName);
 firehoseRecorder.saveRecord("Streaming data to S3 via Firehose is easy.\n", streamName);
 
 // send previously save data to Amazon Firehose
 // Note: submitAllRecords() makes network calls, so wrap it in an AsyncTask.
 new AsyncTask<Void, Void, Void>() {
     @Override
     protected Void doInBackground(Void... v) {
         try {
             firehoseRecorder.submitAllRecords();
         } catch (AmazonClientException ace) {
             // error occurs.
         }
     }
 }.execute();
 
Skip navigation links

Copyright © 2018 Amazon Web Services, Inc. All Rights Reserved.