BooConn Marketing Helped me a lot with my Book Sales

I wrote a book called “Humans” that I self-published with AuthorHouse way back 2011. I never got something in return after self-publishing with them and I mean who wouldn’t be discouraged to buy my…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Taking the first step towards serverless computing

Serverless computing may be the hottest thing in cloud computing today, but what, exactly, is it? In fact, it is considered disruptive to traditional cloud computing and serverless computing simply means that you, the developer, does not have to deal with the server. A serverless computing platform like AWS Lambda allows you to build your code and deploy it without ever needing to configure or manage underlying servers. Your unit of deployment is your code; not the container that hosts the code, or the server that runs the code, but simply the code itself.

AWS Lambda is an example of a framework that makes it possible to write and deploy functions that represent the serverless computing paradigm.

To enable AWS lambda, we need the following dependency in our project:

Simply put, to invoke a lambda function, we need to specify a handler; there are 3 ways of creating a handler:

Let’s see how to do it using code examples.

We’ll create a handler method that will be the entry point for incoming requests. We can use JSON format or primitive data types as input values.

Also, the optional Context object will allow us to access useful information available within the Lambda execution environment:

We can also implement the RequestHandler into our class and override the handleRequest method which will be our entry point for requests:

In this case, the input will be the same as in the first example.

We can also implement RequestStreamHandler in our class and simply override the handleRequest method.

The difference is that InputStream, ObjectStream and Context objects are being passed as parameters:

With everything configured, we can create the deployment file by simply running:

mvn clean package shade:shade

The jar file will be created under the target folder.

Here are the steps required to create our lambda:

Once the AWS lambda function is created, we’ll test it by passing in some data:

On the screen, you can see the Execution result section with successfully returned output as:

"Hello World - AWS Lambda"

In this quick intro article, we’ve created a simple AWS Lambda app using Java 8, deployed that to AWS and tested it.

Add a comment

Related posts:

The Department of Past Future Us

The Department of Past Future Us, a Medium series by Past Future