Skip to content

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

Merged
merged 3 commits into from
Nov 21, 2023

Conversation

rtananthan
Copy link
Contributor

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.

Copy link

@eldritchideen eldritchideen left a 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) {

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);

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.

Copy link
Contributor Author

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

Copy link

@eldritchideen eldritchideen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@yualexan yualexan merged commit c8a7461 into aws-samples:main Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants