-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from IanMeyers/master
Adding Sample Lambda Code
- Loading branch information
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import java.util.List; | ||
|
||
import com.amazonaws.kinesis.deagg.RecordDeaggregator; | ||
import com.amazonaws.services.kinesis.clientlibrary.types.UserRecord; | ||
import com.amazonaws.services.lambda.runtime.Context; | ||
import com.amazonaws.services.lambda.runtime.LambdaLogger; | ||
import com.amazonaws.services.lambda.runtime.RequestHandler; | ||
import com.amazonaws.services.lambda.runtime.events.KinesisEvent; | ||
import com.amazonaws.services.lambda.runtime.events.KinesisEvent.KinesisEventRecord; | ||
|
||
public class EchoHandler implements RequestHandler<KinesisEvent, Void> { | ||
|
||
@Override | ||
public Void handleRequest(KinesisEvent event, Context context) { | ||
LambdaLogger logger = context.getLogger(); | ||
|
||
// extract the records from the event | ||
List<KinesisEventRecord> records = event.getRecords(); | ||
|
||
logger.log(String.format("Recieved %s Raw Records", records.size())); | ||
|
||
// now deaggregate the message contents | ||
List<UserRecord> deaggregated = new RecordDeaggregator<KinesisEventRecord>().deaggregate(records); | ||
logger.log(String.format("Received %s Deaggregated User Records", deaggregated.size())); | ||
|
||
deaggregated.stream().forEachOrdered(rec -> { | ||
logger.log(rec.getPartitionKey()); | ||
}); | ||
|
||
return null; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
java/KinesisDeaggregator/src/sample/java/SampleLambdaEvent.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"Records": [ | ||
{ | ||
"kinesis": { | ||
"partitionKey": "partitionKey-03", | ||
"kinesisSchemaVersion": "1.0", | ||
"data": "84mawgoDYWJjEicxOTE0MTU2NTgzNDQxNTg3NjYxNjgwMzE0NzMyNzc5MjI4MDM1NzAaIAgAEAAaGmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6GiAIABAAGhp6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYRogCAAQABoaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoaIAgAEAAaGnp5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhGiAIABAAGhphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ehogCAAQABoaenl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmEaIAgAEAAaGmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6GiAIABAAGhp6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYRogCAAQABoaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoaIAgAEAAaGnp5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhGiAIABAAGhphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ehogCAAQABoaenl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmEaIAgAEAAaGmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6GiAIABAAGhp6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYRogCAAQABoaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoaIAgAEAAaGnp5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhGiAIABAAGhphYmNkZWZnaGlqa2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4eXoaIAgAEAAaGnp5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhGiAIABAAGhphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ehogCAAQABoaenl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmEaIAgAEAAaGmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6GiAIABAAGhp6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYRogCAAQABoaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoaIAgAEAAaGnp5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhGiAIABAAGhphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ehogCAAQABoaenl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmEaIAgAEAAaGmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6GiAIABAAGhp6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYRogCAAQABoaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoaIAgAEAAaGnp5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2Jh0I8WvwEDJiGD4YsiKIfUOw==", | ||
"sequenceNumber": "49545115243490985018280067714973144582180062593244200961", | ||
"approximateArrivalTimestamp": 1428537600 | ||
}, | ||
"eventSource": "aws:kinesis", | ||
"eventID": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", | ||
"invokeIdentityArn": "arn:aws:iam::EXAMPLE", | ||
"eventVersion": "1.0", | ||
"eventName": "aws:kinesis:record", | ||
"eventSourceARN": "arn:aws:kinesis:EXAMPLE", | ||
"awsRegion": "us-east-1" | ||
} | ||
] | ||
} |