-
Notifications
You must be signed in to change notification settings - Fork 16
Getting Started
In order to create a Lambda function compatible with mParticle Firehose you'll be creating a Lambda function just like any other, and then using the Java library in this repository to parse and facilitate communication in between mParticle and your function.
mParticle has created a sample project to get you started quicker, but it may also be useful to read an overview on AWS Lambda here: http://docs.aws.amazon.com/lambda/latest/dg/java-gs.html
In order to get started quicker, you can clone the sample project located here:
https://github.com/mParticle/lambda-extension-sample
The sample project takes care of the basics of creating a lambda function for you. Most importantly it includes a class that implements the RequestStreamHandler
interface of the Amazon AWS lambda SDK. When data is received by the RequestStreamHandler
, it's deserialized by the mParticle Java SDK into POJOs to be used by you, as in the following snippet:
/**
* Sample AWS Lambda Endpoint
*/
public class SampleLambdaEndpoint implements RequestStreamHandler {
@Override
public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException {
SampleExtension processor = new SampleExtension(); //you will implement this class in a later step
MessageSerializer serializer = new MessageSerializer(); //mParticle class for deserialization
Message request = serializer.deserialize(input, Message.class);
Message response = processor.processMessage(request); //request is processed by you here
serializer.serialize(output, response);
}
}
In the example above, incoming data is deserialized to a Message
object, and passed in to SampleExtension
. SampleExtension
is any class that extends the mParticle Java SDK's MessageProcessor
- which you will implement. This will serve as the entry point to all of your logic and ultimately, the 3rd-party service to which you're integrating.
Continue on to Implementing the MessageProcessor to learn the types of Message
objects and how to process them.