Skip to content

Commit 5a3c8d7

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 5dde5d7 + c8a7461 commit 5a3c8d7

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package example;
2+
3+
import com.amazonaws.services.lambda.runtime.Context;
4+
import com.amazonaws.services.lambda.runtime.LambdaLogger;
5+
import com.amazonaws.services.lambda.runtime.RequestHandler;
6+
import com.amazonaws.services.lambda.runtime.events.KinesisEvent;
7+
8+
public class Handler implements RequestHandler<KinesisEvent, Void> {
9+
@Override
10+
public Void handleRequest(final KinesisEvent event, final Context context) {
11+
LambdaLogger logger = context.getLogger();
12+
if (event.getRecords().isEmpty()) {
13+
logger.log("Empty Kinesis Event received");
14+
return null;
15+
}
16+
for (KinesisEvent.KinesisEventRecord record : event.getRecords()) {
17+
try {
18+
logger.log("Processed Event with EventId: "+record.getEventID());
19+
String data = new String(record.getKinesis().getData().array());
20+
logger.log("Data:"+ data);
21+
// TODO: Do interesting work based on the new data
22+
}
23+
catch (Exception ex) {
24+
logger.log("An error occurred:"+ex.getMessage());
25+
throw ex;
26+
}
27+
}
28+
logger.log("Successfully processed:"+event.getRecords().size()+" records");
29+
return null;
30+
}
31+
32+
}

integration-kinesis-to-lambda/snippet-data.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Using AWS Lambda with Amazon Kinesis without Batch Item Handling.",
44
"type": "Integration",
55
"services": ["lambda", "kinesis"],
6-
"languages": ["Node", "TypeScript", ".NET"],
6+
"languages": ["Node", "TypeScript", ".NET", "Java"],
77
"tags": [],
88
"introBox": {
99
"headline": "How it works",
@@ -53,6 +53,17 @@
5353
}
5454
]
5555
},
56+
{
57+
"id": "Java",
58+
"title": "Usage Example with Java",
59+
"description": "Consuming Kinesis event with Lambda using Java without batch item handling.",
60+
"snippets": [
61+
{
62+
"snippetPath": "Handler.java",
63+
"language": "java"
64+
}
65+
]
66+
},
5667
{
5768
"id": "Go",
5869
"title": "Usage Example with Go:",
@@ -83,6 +94,13 @@
8394
"bio": "Cloud Application Architect at AWS",
8495
"linkedin": "mtomeh",
8596
"twitter": "mtomeh84"
97+
},
98+
{
99+
"headline": "Java Example Presented by Ananthan Rudran",
100+
"name": "Ananthan Rudran",
101+
"image": "https://pbs.twimg.com/profile_images/888727786797412352/DEZ1mRjs_400x400.jpg",
102+
"bio": "Solutions Architect Architect at AWS",
103+
"linkedin": "ananthanr"
86104
}
87105
]
88106
}

0 commit comments

Comments
 (0)