尝试测试本地兔子时,接收NullPoInterException
我已经使用@timertrigger和@rabbitmqoutput注释设置了基本的Azure函数: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-rabbitmq?tabs = in-process&pivots = pivots = progivots = programming-language-java
public class RabbitMQFunction {
private static final Logger logger = LoggerFactory.getLogger(RabbitMQFunction.class);
/**
* This function will be invoked periodically according to the specified schedule.
*/
@FunctionName("RabbitMQFunction")
public void run(
@TimerTrigger(name = "timerInfo", schedule = "*/15 * * * * *") String timerInfo,
@RabbitMQOutput(connectionStringSetting = "rabbitMQConnectionAppSetting", queueName = "myQueue", disableCertificateValidation = true) OutputBinding<String> output,
final ExecutionContext context
) {
logger.debug("START - RabbitMQFunction");
context.getLogger().info("Java Timer trigger function executed at: " + LocalDateTime.now());
output.setValue("Some string");
logger.debug("END - RabbitMQFunction");
}
}
不幸的是,我在Visual Studio代码中使用Azurite本地测试时,在输出中接收以下错误。这是堆栈跟踪:
[2022-05-24T13:46:48.878Z] Received FunctionLoadResponse for function: 'RabbitMQFunction' with functionId: 'b09d265b-8b35-478f-8657-da7cf5b0fbc6'.
[2022-05-24T13:46:49.529Z] Host lock lease acquired by instance ID '000000000000000000000000CEA4F55C'.
[2022-05-24T13:47:00.087Z] Executing 'Functions.RabbitMQFunction' (Reason='Timer fired at 2022-05-24T09:47:00.0322362-04:00', Id=a34b49d5-603f-4977-92f0-672f0d5feb86)
[2022-05-24T13:47:00.243Z] InvocationResponse received for invocation id: 'a34b49d5-603f-4977-92f0-672f0d5feb86'
[2022-05-24T13:47:00.325Z] Executed 'Functions.RabbitMQFunction' (Failed, Id=a34b49d5-603f-4977-92f0-672f0d5feb86, Duration=265ms)
[2022-05-24T13:47:00.327Z] System.Private.CoreLib: Exception while executing function: Functions.RabbitMQFunction. System.Private.CoreLib: Result: Failure
Exception: NullPointerException:
Stack: java.lang.NullPointerException
[2022-05-24T13:47:00.329Z] at com.microsoft.azure.functions.worker.binding.BindingDataStore.isDataTargetValid(BindingDataStore.java:145)
[2022-05-24T13:47:00.331Z] at com.microsoft.azure.functions.worker.binding.BindingDataStore.getOrAddDataTarget(BindingDataStore.java:123)
[2022-05-24T13:47:00.333Z] at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:56)
[2022-05-24T13:47:00.334Z] at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:42)
[2022-05-24T13:47:00.336Z] at com.microsoft.azure.functions.worker.broker.EnhancedJavaMethodExecutorImpl.execute(EnhancedJavaMethodExecutorImpl.java:53)
[2022-05-24T13:47:00.338Z] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:61)
[2022-05-24T13:47:00.339Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33)
[2022-05-24T13:47:00.341Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
[2022-05-24T13:47:00.342Z] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45)
[2022-05-24T13:47:00.344Z] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92)
[2022-05-24T13:47:00.345Z] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[2022-05-24T13:47:00.347Z] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[2022-05-24T13:47:00.349Z] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[2022-05-24T13:47:00.351Z] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[2022-05-24T13:47:00.352Z] at java.base/java.lang.Thread.run(Thread.java:829)
[2022-05-24T13:47:00.354Z] .
host.json包含:
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
}
local.settings.json包含:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "java",
"rabbitMQConnectionAppSetting": "amqp://guest:[email protected]:5672/"
}
}
build.gradle包含:
implementation 'com.microsoft.azure.functions:azure-functions-java-library:2.0.1'
implementation 'com.microsoft.azure.functions:azure-functions-java-library-rabbitmq:1.0.0'
// I've also tried with 2.0.0-preview
有人可以指出我在做什么错吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的
getLogger()
函数是获取NULL指针异常的原因。如果您不提供Logger名称,则此功能将引发此异常。
因此,它应该看起来像:
请参阅此 Javapoint的文章。
The
getLogger()
function you have used is the reason for getting the null pointer exception.This function will throw this exception if you don't provide a logger name.
So, this it should look like:
Refer this following article from javapoint.