简体   繁体   English

C# AWS Lambda 函数异常处理

[英]C# AWS Lambda functions exception handling

c# aws lambda函数异常处理可以在全局方法中完成还是仅在每个函数中单独完成?

If you want to handle problems in all of your functions it might be a good ideia to use a Dead Letter Queue that triggers a exception handling function.如果您想处理所有函数中的问题,使用触发异常处理函数的死信队列可能是一个好主意。

Dead letter queue (DLQ) is an AWS Lambda feature that stores the messages that triggered the lambda and threw non user handled exceptions.死信队列(DLQ) 是 AWS Lambda 的一项功能,用于存储触发 lambda 并引发非用户处理异常的消息。

Then you can setup an AWS Simple Notification Topic to listen to this queue and trigger a second lambda function that handles your global errors.然后,您可以设置AWS 简单通知主题来侦听此队列并触发第二个 lambda 函数来处理您的全局错误。

It is easier done than said, haha.做起来比说的容易,哈哈。 I recommend trying it.我建议尝试一下。

You can use this Robust Serverless Application Design post as a guide.您可以使用这篇强大的无服务器应用程序设计文章作为指南。

To answer your question: No, neither the Lambda runtime or .Net Core support global exception handlers (ASP.Net Core does but that wasn't your question).回答您的问题:不,Lambda 运行时或 .Net Core 都不支持全局异常处理程序(ASP.Net Core 支持但那不是您的问题)。 This would be an excellent addition to the Lambda runtime for .Net Core, or perhaps as a Lambda Layer.这将是 .Net Core 的 Lambda 运行时的极好补充,或者作为 Lambda 层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM