{"id":18010874,"url":"https://github.com/yokawasa/kinesis-consumer","last_synced_at":"2026-04-24T21:31:27.477Z","repository":{"id":66860497,"uuid":"378525958","full_name":"yokawasa/kinesis-consumer","owner":"yokawasa","description":"Sample KCL 2.X consumer for AWS Kinesis streams. The consumer is configurable via environmental variables and can be containerized (dockerfile for it is provided), which can be run anywhere","archived":false,"fork":false,"pushed_at":"2021-09-11T00:36:39.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-17T00:42:57.201Z","etag":null,"topics":["aws","containers","java","kinesis","kinesis-consumer"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yokawasa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-20T00:03:40.000Z","updated_at":"2022-12-02T01:52:07.000Z","dependencies_parsed_at":"2023-03-11T00:24:18.251Z","dependency_job_id":null,"html_url":"https://github.com/yokawasa/kinesis-consumer","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/yokawasa/kinesis-consumer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokawasa%2Fkinesis-consumer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokawasa%2Fkinesis-consumer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokawasa%2Fkinesis-consumer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokawasa%2Fkinesis-consumer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yokawasa","download_url":"https://codeload.github.com/yokawasa/kinesis-consumer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokawasa%2Fkinesis-consumer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32241521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","containers","java","kinesis","kinesis-consumer"],"created_at":"2024-10-30T02:15:35.213Z","updated_at":"2026-04-24T21:31:27.455Z","avatar_url":"https://github.com/yokawasa.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kinesis-consumer\n\nSample [KCL 2.X consumer](https://docs.aws.amazon.com/streams/latest/dev/enhanced-consumers.html) for AWS Kinesis streams. The consumer is configurable via environmental variables and can be containerized (dockerfile for it is provided), which can be run anywhere.\n\n\n**Table of Contents**\n\u003c!-- TOC --\u003e\n\n- [kinesis-consumer](#kinesis-consumer)\n\t- [Quickstart](#quickstart)\n\t\t- [Create Kinesis Data Stream](#create-kinesis-data-stream)\n\t\t- [Configurations](#configurations)\n\t\t- [Create the package](#create-the-package)\n\t\t- [Run the consumer](#run-the-consumer)\n\t- [Publish data to Kinesis](#publish-data-to-kinesis)\n\n\u003c!-- /TOC --\u003e\n\n## Quickstart\n\nBefore running the samples, you'll want to make sure that your environment is configured to allow the samples to use your [AWS Security Credentials](https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html).\n\n### Create Kinesis Data Stream\n\nYou can create the the Kinesis data stream with AWS CLI.\n\n```bash\nSTREAM_NAME=test-kds01\nREGION=ap-northeast-1\n\naws kinesis create-stream --stream-name ${STREAM_NAME} --shard-count 1 --region ${REGION}\n\n# describe the stream\naws kinesis describe-stream-summary --stream-name ${STREAM_NAME}\n\n# list\naws kinesis list-streams\n```\n\nref: [Perform Basic Kinesis Data Stream Operations Using the AWS CLI](https://docs.aws.amazon.com/streams/latest/dev/fundamental-stream.html)\n\n### Configurations\n\nEnviroment Variables to configure the Kinesis Consumer\n\n|Parameter|Required|Default Value|Description|\n|:--:|:--:|:--:|:--|\n|`KINESIS_APPLICATION_NAME`|`true`| `\"\"`| Kinesis KCL Application name |\n|`KINESIS_STREAM_NAME`|`true`|`\"\"`| Kinesis Stream Name |\n|`KINESIS_REGION`|`false`|`\"ap-northeast-1\"`| Kinesis Region |\n|`KINESIS_INITIAL_POSITION_IN_STREAM`|`false`|`\"LATEST\"`| Initial Position in Stream: `LATEST` or `TRIM_HORIZON` |\n|`KINESIS_IDLETIME_BETWEEN_READS_MILLIS`|`false`|`1000` | Idle time between record reads in milliseconds |\n|`KINESIS_FAILOVER_TIME_MILLIS`|`false`|`10000` | Fail over time in milliseconds. A worker which does not renew it's lease within this time interval will be regarded as having problems and it's shards will be assigned to other workers. For applications that have a large number of shards, this msy be set to a higher number to reduce the number of DynamoDB IOPS required for tracking leases |\n|`KINESIS_MAX_RECORDS`|`false`|`10000`| Max records to fetch per Kinesis getRecords call |\n\n\n\nConfigure the consumer with enviromental variables like this and save the file (let's say `myconfig.env`)\n\n```bash\nexport KINESIS_APPLICATION_NAME=\"\u003ckinesis application name\u003e\"\nexport KINESIS_STREAM_NAME=\"\u003ckinesis stream name\u003e\"\nexport KINESIS_REGION=\"\u003ckinesis region: ap-northeast-1\u003e\"\nexport KINESIS_IDLETIME_BETWEEN_READS_MILLIS=\"\u003cidle time between record reads in milliseconds: default 1000\u003e\"\nexport KINESIS_INITIAL_POSITION_IN_STREAM=\"\u003cinitial Position In Stream: LATEST or TRIM_HORIZON\u003e\"\nexport KINESIS_FAILOVER_TIME_MILLIS=\"\u003cfailover time millis: default 10000\u003e\"\nexport KINESIS_MAX_RECORDS=\"\u003cmax records to fetch per Kinesis getRecords call: default 10000\u003e\"\n\nexport JAVA_HEAP_XMX=512M\nexport JAVA_HEAP_XMS=512M\n```\n\n### Create the package\n\nBuild and create the package\n```\nmake \n```\nor You can create the package with `mvn` command\n```\nmvn package\n```\n\n### Run the consumer\n\nYou can run the consumer app with the configuration files (`myconfig.env`)\n\n```bash\n./helpers/run_local_consumer.sh myconfig.env\n```\n\nOr you can run a conatinized consumer app. You need to give the following 2 args\n- App configuration file (`myconfig.env`)\n- AWS Profile name that you use to interact with AWS resources (`my-aws-profile`)\n\n```bash\n./helpers/run_docker_consumer.sh myconfig.env my-aws-profile\n```\n\nHere is an sample output:\n```\n./helpers/run_docker_consumer.sh ./myconfig.env my-aws-profile\n\n21-07-27 20:32:47:661  INFO main kinesis.KinesisConfig:137 - applkicationName: mykclapp01 [env KINESIS_APPLICATION_NAME: mykclapp01]\n21-07-27 20:32:47:663  INFO main kinesis.KinesisConfig:139 - streamName: test-kds01 [env KINESIS_STREAM_NAME: test-stream01]\n21-07-27 20:32:47:664  INFO main kinesis.KinesisConfig:141 - region: ap-northeast-1 [env KINESIS_REGION: ap-northeast-1]\n21-07-27 20:32:47:664  INFO main kinesis.KinesisConfig:143 - idleTimeBetweenReadsInMillis: 1000 [env KINESIS_IDLETIME_BETWEEN_READS_MILLIS: null]\n21-07-27 20:32:47:665  INFO main kinesis.KinesisConfig:145 - initialPositionInStream: LATEST [env KINESIS_INITIAL_POSITION_IN_STREAM: null]\n21-07-27 20:32:47:665  INFO main kinesis.KinesisConfig:147 - failoverTimeMillis: 10000 [env KINESIS_FAILOVER_TIME_MILLIS: null]\n21-07-27 20:32:47:667  INFO main kinesis.KinesisConfig:149 - maxRecords: 10000 [env KINESIS_MAX_RECORDS: null]\n21-07-27 20:32:48:037  INFO main dynamodb.DynamoDBLeaseCoordinator:170 - With failover time 10000 ms and epsilon 25 ms, LeaseCoordinator will renew leases every 3308 ms, takeleases every 20050 ms, process maximum of 2147483647 leases and steal 1 lease(s) at a time. Press enter to shutdown\n21-07-27 20:32:48:044  INFO Thread-1 coordinator.Scheduler:263 - Initialization attempt 1\n21-07-27 20:32:48:045  INFO Thread-1 coordinator.Scheduler:264 - Initializing LeaseCoordinator\n21-07-27 20:32:53:681  INFO Thread-1 coordinator.Scheduler:269 - Syncing Kinesis shard info\n21-07-27 20:32:54:017  INFO Thread-1 coordinator.Scheduler:280 - Starting LeaseCoordinator\n21-07-27 20:32:54:037  INFO Thread-1 coordinator.Scheduler:238 - Initialization complete. Starting worker loop.\n21-07-27 20:32:54:054  INFO LeaseCoordinator-0000 dynamodb.DynamoDBLeaseTaker:389 - Worker 5a9a7d70-61bc-46cc-9882-142a144ae2e7 needed 1 leases but none were expired, so it will steal lease shardId-000000000001 from 4bc1b045-6858-4165-a6b4-845b290e68b4\n21-07-27 20:32:54:055  INFO LeaseCoordinator-0000 dynamodb.DynamoDBLeaseTaker:397 - Worker 5a9a7d70-61bc-46cc-9882-142a144ae2e7 saw 2 total leases, 0 available leases, 2 workers. Target is 1 leases, I have 0 leases, I will take 1 leases\n21-07-27 20:32:54:108  INFO LeaseCoordinator-0000 dynamodb.DynamoDBLeaseTaker:203 - Worker 5a9a7d70-61bc-46cc-9882-142a144ae2e7 successfully took 1 leases: shardId-000000000001\n21-07-27 20:32:55:056  INFO Thread-1 coordinator.Scheduler:682 - Created new shardConsumer for : ShardInfo(shardId=shardId-000000000001, concurrencyToken=16582df2-200f-4f7e-8edc-c7dc677f0220, parentShardIds=[], checkpoint={SequenceNumber: LATEST,SubsequenceNumber: 0})\n21-07-27 20:32:55:058  INFO ShardRecordProcessor-0000 lifecycle.BlockOnParentShardTask:78 - No need to block on parents [] of shard shardId-000000000001\n21-07-27 20:32:56:091  INFO ShardRecordProcessor-0000 polling.KinesisDataFetcher:182 - Initializing shard shardId-000000000001 with LATEST\n21-07-27 20:32:56:153  INFO ShardRecordProcessor-0000 polling.PrefetchRecordsPublisher:237 - shardId-000000000001 : Starting prefetching thread.\n21-07-27 20:32:56:156  INFO ShardRecordProcessor-0000 kinesis.SampleKinesisConsumer$SampleRecordProcessor:202 - Initializing @ Sequence: {SequenceNumber: LATEST,SubsequenceNumber: 0}\n21-07-27 20:33:14:178  INFO LeaseCoordinator-0000 dynamodb.DynamoDBLeaseTaker:397 - Worker 5a9a7d70-61bc-46cc-9882-142a144ae2e7 saw 2 total leases, 1 available leases, 1 workers. Target is 2 leases, I have 1 leases, I will take 1 leases\n21-07-27 20:33:14:198  INFO LeaseCoordinator-0000 dynamodb.DynamoDBLeaseTaker:203 - Worker 5a9a7d70-61bc-46cc-9882-142a144ae2e7 successfully took 1 leases: shardId-000000000000\n21-07-27 20:33:15:138  INFO Thread-1 coordinator.Scheduler:682 - Created new shardConsumer for : ShardInfo(shardId=shardId-000000000000, concurrencyToken=270d7175-ec4f-488a-98a0-be42e76557f3, parentShardIds=[], checkpoint={SequenceNumber: LATEST,SubsequenceNumber: 0})\n21-07-27 20:33:48:227  INFO Thread-1 coordinator.DiagnosticEventLogger:41 - Current thread pool executor state: ExecutorStateEvent(executorName=SchedulerThreadPoolExecutor, currentQueueSize=0, activeThreads=0, coreThreads=0, leasesOwned=2, largestPoolSize=2, maximumPoolSize=2147483647)\n21-07-27 20:33:48:227  INFO Thread-1 coordinator.Scheduler:677 - Sleeping ...\n21-07-27 20:34:05:270  INFO ShardRecordProcessor-0000 kinesis.SampleKinesisConsumer$SampleRecordProcessor:218 - Processing 8 record(s)\n21-07-27 20:34:05:271  INFO ShardRecordProcessor-0000 kinesis.SampleKinesisConsumer$SampleRecordProcessor:244 - PartitionKey: 123 SequenceNumber: 49619723974008913634774903261799205369756139518011899906 Arrived(milsec ago): 1157 Data: testmsg\n21-07-27 20:34:05:271  INFO ShardRecordProcessor-0000 kinesis.SampleKinesisConsumer$SampleRecordProcessor:244 - PartitionKey: 123 SequenceNumber: 49619723974008913634774903261802832147214983405536018434 Arrived(milsec ago): 1144 Data: testmsg\n21-07-27 20:34:05:271  INFO ShardRecordProcessor-0000 kinesis.SampleKinesisConsumer$SampleRecordProcessor:244 - PartitionKey: 123 SequenceNumber: 49619723974008913634774903261805249998854212663885430786 Arrived(milsec ago): 1127 Data: testmsg\n21-07-27 20:34:05:271  INFO ShardRecordProcessor-0000 kinesis.SampleKinesisConsumer$SampleRecordProcessor:244 - PartitionKey: 123 SequenceNumber: 49619723974008913634774903261806458924673827293060136962 Arrived(milsec ago): 1111 Data: testmsg\n21-07-27 20:34:05:271  INFO ShardRecordProcessor-0000 kinesis.SampleKinesisConsumer$SampleRecordProcessor:244 - PartitionKey: 123 SequenceNumber: 49619723974008913634774903261808876776313056551409549314 Arrived(milsec ago): 1096 Data: testmsg\n21-07-27 20:34:05:271  INFO ShardRecordProcessor-0000 kinesis.SampleKinesisConsumer$SampleRecordProcessor:244 - PartitionKey: 123 SequenceNumber: 49619723974008913634774903261813712479591515068108374018 Arrived(milsec ago): 1083 Data: testmsg\n21-07-27 20:34:05:271  INFO ShardRecordProcessor-0000 kinesis.SampleKinesisConsumer$SampleRecordProcessor:244 - PartitionKey: 123 SequenceNumber: 49619723974008913634774903261816130331230744326457786370 Arrived(milsec ago): 1067 Data: testmsg\n```\n\n## Publish data to Kinesis\n\nUsing a Golang tool named [kinesis-bulk-loader](https://github.com/yokawasa/kinesis-bulk-loader), you can put bulk messages in parallel to AWS Kinesis Data Stream.\n\nYou can download and run the tool like this:\n\n```\n# Download the compiled command\ncurl -sS https://raw.githubusercontent.com/yokawasa/kinesis-bulk-loader/main/downloader | bash --\n\n# Run the downloaded command\nkinesis-bulk-loader -stream test-kds01 -k hoge -m test -c 10 -n 100 -verbose\n```\n\nFor more information, see GitHub [kinesis-bulk-loader](https://github.com/yokawasa/kinesis-bulk-loader).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyokawasa%2Fkinesis-consumer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyokawasa%2Fkinesis-consumer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyokawasa%2Fkinesis-consumer/lists"}