'micronaut and graalvm: define aws lambda event handler
I'm working on aws lambda project with java, micronaut, graalvm and sam.
I was able to successfully compile and deploy the app. However, I don't understand how to set a event handling: let's say I want my lambda to run on schedule every minute.
I tried different settings, but my current setup looks this way. sam config:
Resources:
GraalvmFunction:
Type: AWS::Serverless::Function
Properties:
Handler: helloworld.ScheduledHandler2::execute
Runtime: provided
CodeUri: build/libs/graalvm-poc-0.1-lambda.zip
MemorySize: 256
Timeout: 100
Events:
HWScheduler:
Type: Schedule
Properties:
Schedule: "rate(1 minute)"
Name: HWScheduler
Enabled: True
Handler's code:
@FunctionBean
public class ScheduledHandler2 extends MicronautRequestHandler<ScheduledEvent, Void> {
private static final Logger log = LoggerFactory.getLogger("graalvm-poc");
private static final Object object = new Object();
@Override
public Void execute(ScheduledEvent input) {
log.info("it works2 " + object.toString());
return null;
}
}
In the logs I only see:
2022-02-18T18:58:26.840+01:00 [36m17:58:26.832[0;39m [1;30m[main][0;39m [34mINFO [0;39m [35mi.m.f.a.p.AbstractLambdaContainerHandler[0;39m - Starting Lambda Container Handler
2022-02-18T18:58:26.925+01:00 [36m17:58:26.925[0;39m [1;30m[main][0;39m [34mINFO [0;39m [35mi.m.context.env.DefaultEnvironment[0;39m - Established active environments: [ec2, cloud, lambda, function]
2022-02-18T18:58:27.046+01:00 START RequestId: 13c4a9b3-9bc8-4737-9f77-b1f7df141a7c Version: $LATEST
2022-02-18T18:58:27.376+01:00 END RequestId: 13c4a9b3-9bc8-4737-9f77-b1f7df141a7c
2022-02-18T18:58:27.376+01:00 REPORT RequestId: 13c4a9b3-9bc8-4737-9f77-b1f7df141a7c Duration: 326.72 ms Billed Duration: 721 ms Memory Size: 256 MB Max Memory Used: 134 MB Init Duration: 393.71 ms
and nothing happens. Any ideas?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
