Code Monkey home page Code Monkey logo

aws-kinesis-kpl-kcl's Introduction

KPL Java Sample Application

Setup

You will need the following:

  • A stream to put into (with any number of shards). There should be no previous data in the stream, creating a new stream is recommended.
  • AWS credentials, preferably an IAM role if using EC2
  • JDK
  • Maven (brew install maven, sudo apt-get install maven, Amazon Liunx)

Since we'll be running a consumer as well as a producer, the credentials/IAM role should contain permissions for DynamoDB and CloudWatch, in addition to Kinesis. See the official guide for details.

If running locally, set environment variables for the AWS credentials:

export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_KEY=...

If running in EC2, the KPL will automatically retrieve credentials from any associated IAM role.

You can also pass credentials to the KPL programmatically during initialization.

Edit the Sample Application

The sample application is a Maven project. It takes dependencies on the KPL and KCL and contains both a producer and consumer.

Refer to the documentation within the code files for more details about what it's actually doing.

You will need to modify the stream name and region variables in the producer code to point the app at your own stream.

In SampleProducer.java, look for:

/**
 * Change this to your stream name.
 */
public static final String STREAM_NAME = "test";

/**
 * Change this to the region you are using.
 * 
 * We do not use the SDK Regions enum because the KPL does not depend on the
 * SDK.
 */
public static final String REGION = "us-west-1";

Run the Sample

After you've made the necessary changes, do a clean build:

mvn clean package

Then run the producer to put some data into your stream:

mvn exec:java -Dexec.mainClass="com.amazonaws.services.kinesis.producer.sample.SampleProducer"

Finally run the consumer to retrieve that data:

mvn exec:java -Dexec.mainClass="com.amazonaws.services.kinesis.producer.sample.SampleConsumer"

aws-kinesis-kpl-kcl's People

Stargazers

 avatar

Watchers

James Cloos avatar Niko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.