kinesis-client-node is a node.js kinesis client library that interfaces with Amazon's MultiLangDaemon
MIT license
- No warranty or support is implied.
- No representations made towards quality or performance.
- Feel free to raise issues or fork.
- Feedback / Suggestions / Patches welcome.
- Install Java SDK
- Setup the AWS command line utlilities
- Create an IAM role that has access to Kinesis, CloudWatch and DynamoDB
- Create a credentials file - ~/.aws/credentials
- Add a [default] profile with aws_access_key_id and aws_secret_access_key of the IAM role created in step 3
Create a Javascript file named kinesis.app.words.settings.js under coffee/sample/
Add the following settings (replace with real values)
settings = {
"aws" : {
"region" : "AWS Region",
"accessKeyId" : "AWS Access Key",
"secretAccessKey" : "AWS Secret Access Key"
},
"app" : {
"recordProcessor" : {
"streamName" : "Name of Kinesis Stream",
"sleepSeconds" : "Sleep Interval (integer)",
"checkpointRetries" : "Number of checkpoint retries (integer)",
"checkpointFreqSeconds" : "Checkpoint frequency in seconds (integer)"
}
}
}
module.exports = settings
Install package dependencies
npm install
Install gulp globally
npm install -g gulp
Run the setup task to fetch KCL jars
gulp setup
The sample app is a word processor composed of
- A word producer that puts words into a Kinesis stream - kinesis.producer.words.coffee
- A record processor that handles initialialisation, shutdown and record processing - recordprocessor.coffee
- The sample app code that is handed each record recieved by the record processor for processing - kinesis.app.words.coffee
Generate the Java command to start the daemon using
./lib/kclhelper.js --print_command --java /usr/bin/java --props ./lib/sample/ml-daemon.properties
Execute the generated command
The word producer can be invoked by running
./lib/sample/kinesis.producer.words.js
It accepts the following arguments
--stream STREAM_NAME
--region AWS_REGION
--words COMMA_SEP_WORD_LIST
--period PUT_REPEATEDLY_AFTER_MILLIS
Example
./lib/sample/kinesis.producer.words.js --stream words --region ap-southeast-2 --words one,two,three --period 5000
Tail the log file - ./logs/worker.log to see INFO messages generated by KCL
- Testcases