quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

@QuarkusMain not executed with Lambda Function at AWS

Open claudiney-silva opened this issue 3 years ago • 2 comments

Describe the bug

I am building a Lambda Function with Quarkus Funqy. I have a class annoted with @QuarkusMain to do statics initilization for Provisioned concurrency.

@QuarkusMain class is executed with mvn quarkus:dev, but is not executed when Lambda function is called or initilized.

My code looks like below:

@QuarkusMain
public class Main {
    public static void main(String... args) {
        Quarkus.run(MyApp.class, args);
    }

    public static class MyApp implements QuarkusApplication {

        @Override
        public int run(String... args) throws Exception {
            System.out.println("Static initilization");
            Quarkus.waitForExit();
            return 0;
        }
    }
}

public class Sample {

   @Funq
   public String sample(JsonNode event) {
      return "OK";
   }

}

With mvn quarkus:dev it runs properly intellij

But on AWS not aws

The handler configured: io.quarkus.funqy.lambda.FunqyStreamHandler::handleRequest

I already tested with Quarkus 2.10.0 and 2.11.1.

Thanks!

Expected behavior

I expect that on lambda cold start, the @QuarkusMain should be executed.

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.10.0

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

claudiney-silva avatar Aug 02 '22 02:08 claudiney-silva

/cc @matejvasek, @patriot1burke

quarkus-bot[bot] avatar Aug 02 '22 02:08 quarkus-bot[bot]

Hello @claudiney-silva, I think (and please happily ignore what I think as I'm not an expert here!) that Funqy functions don't have lifecycle managed (they are starting and stopping the application themselves), therefore main is never called or some lifecycle events (like ShutdownEvent) are never fired. Invoking Application directly should make boot startup faster.

Judging from io.quarkus.arc.runtime.ArcRecorder#handleLifecycleEvents though, I think StartupEvent could be fired, but I suppose you tried it and it didn't work?

michalvavrik avatar Aug 08 '22 18:08 michalvavrik