AWS Greengrass Core SDK for Java

The AWS Greengrass Core SDK for Java enables Java developers to develop Lambda functions which will run within Greengrass.

Overview

This document provides instructions for preparing your Greengrass Core environment to run Lambda functions written in Java. It also includes examples on how to develop a Lambda function in Java as well as packaging and running an example Hello World file in Java for your Greengrass core.

Changes to 1.3.1

Changes to 1.3.0

Changes to 1.2.0

Changes to 1.1.0

Preparing your Greengrass to run Java Lambda functions

The environment where Greengrass is running on needs to be able to run Java 8 packages.

Getting Started - Hello World

Creating a .zip Deployment Package

You can use any building and packaging tool you like to create this zip. Regardless of the tools you use, the resulting .zip file must have the following structure:

All the examples and instructions in this manual use Gradle build and deployment tool to create the .zip.

Downloading Gradle

You will need to download Gradle. For instructions, go to the gradle website, https://gradle.org/

Including Greengrass Core SDK for Java with your function with Gradle

For Greengrass, follow the steps below.

Logging in Java Lambdas

Your System.out.println operation will be logged as INFO. A System.err.println operation will be logged as ERROR. Alternatively, you can also log using context.getLogger().log operation which will log at INFO level. Currently, our Java SDK only allows you to log at INFO or ERROR level only.

Supported Datatypes

From GGC version 1.5.0, you can send binary data with the SDK. However, in order to make a lambda function be able to handle binary payload. You need to do the following:

Supported Function Signatures

In addition to the function signatures mentioned above, there are also more supported function signatures being introduced:

Handler Overload Resolution

If your Java code contains multiple methods with same name as the handler name, then GGC uses the following rules to pick a method to invoke:

Supported Context

In Greengrass, you can send a context object in a JSON format to be passed to another Lambda that is being invoked. The context format looks like this: { custom: { customData: 'customData', }, }

Compatibility

As new features are added to AWS Greengrass, previous versions of the Greengrass SDK will be incompatible with newer versions of the AWS Greengrass core. The following table lists the compatible SDKs for all GGC releases.

GGC Version Compatible SDK Versions
1.0.x-1.6.x 1.0.x-1.2.x
1.7.x 1.0.x-1.3.x

Getting Help

License