-
Notifications
You must be signed in to change notification settings - Fork 98
Added Java Code for Kinesis Lambda Integration #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may be able to simplify the decoding of the Kinesis record data. Take a look at the suggested change.
|
||
public class Handler implements RequestHandler<KinesisEvent, Void> { | ||
@Override | ||
public Void handleRequest(KinesisEvent event, Context context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event
and context
can be made final
.
for (KinesisEvent.KinesisEventRecord record : event.getRecords()) { | ||
try { | ||
logger.log("Processed Event with EventId: "+record.getEventID()); | ||
String data = decodeRecordData(record.getKinesis().getData(),context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the manual decoding logic from a ByteBuffer to String could be simplified for the example to the following.
String data = new String(record.getKinesis().getData().array());
This will decode the byte array using the default decode which should be UTF-8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. They have been incorporated now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.