Quarkus Apache Camel AWS Lambda CDI生成器模板结果为空指针异常

ddrv8njm  于 2022-11-07  发布在  Apache
关注(0)|答案(1)|浏览(146)

我试着在我自己的代码Quarkus Camel AWS Lambda中重现下面的代码Deploying a Camel Route in AWS Lambda : A Camel Quarkus example,但是ProducerTemplate返回NullPointerExcetion,如链接BUG_CAMEL_QUARKUS_LAMBDA所示

@Named("languageScoreLambda")
public class LanguageScoreLambda implements RequestHandler<Language, LanguageScoreDto> {

  @Inject
  ProducerTemplate template;

  @Override
  public LanguageScoreDto handleRequest(Language input, Context context) {
    System.out.println("#Template isNull ===> " + (null == template)); // true
    return new LanguageScoreDto("5", input.getLanguage());
  }
}
e5njpo68

e5njpo681#

我发现了这个问题,因为我一直在使用Terraform来提供AWS Lambda函数,处理程序必须是io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest 在被截取的原始代码下面

resource "aws_lambda_function" "hello_lambda" {
  function_name    = var.AWS_LAMBDA_FUNCTION_NAME
  filename         = "${path.module}/function.zip"
  role             = aws_iam_role.hello_lambda_role.arn
  depends_on       = [aws_cloudwatch_log_group.hello_lambda_logging]
  runtime          = "java11"
  handler          = io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest
  timeout          = 10
  memory_size      = 256
}

相关问题