-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dead-Letter message on permanent failure #2087
Comments
/cc @mathewc - some of the details here don't look accurate, can you comment and provide some guidance? |
@fabiocav - this issue arises from the same fault as both #2085 and #2086 - but it remains a distinct issue that can be fixed separately and distinctly from the other two issues. The 3 issues have been very carefully worded to distinguish them from each other although they are very closely related. |
By default, the message lifetime handling you get out of the box is as follows:
See this issue for details on handling message Completion/DeadLetter yourself. Basically you can set AutoComplete to false in your ServiceBus host.json config (serviceBus.messageHandlerOptions.autoComplete) and handle the message state transitions yourself in your function (see code examples in linked issue). Regarding your comment "When the client function throws any exception Let me know if this addresses the issue for you. If not we can reopen. |
@mathewc - an azure webjob as a console application will restart the console application if an exception is thrown and unhanded. This makes sense, except that throwing an unhanded exception is the only way to have the webjob invocation report failure. This pattern breaks Application Insights ability to capture snapshot debugging details. The AppInsights team didn't seem to have a way around the process exiting before the snapshot completed transferring. What is needed is either changing the return type from void to something meaningful, or permit setting a property or calling some function to signal invocation failure. |
See my comment above "If a single function invocation fails the host doesn't restart - just that invocation fails.". You can see this yourself by running your WebJob locally and throwing an exception from your job method. If you're not seeing such behavior, please provide a repro. |
@mathewc - this may be the intended behaviour - however we have experienced a full restart under some circumstances. I have attempted to reproduce the conditions in isolation. |
@mathewc - webjob invocation, not function. Invocation by queue or timer seems to terminate and restart the console app every time. This breaks app insights ability to capture snapshot debugging. I went through this with them (app insights team) via email and so I'm here asking about the sdk to see if there is a way to report invocation failure without restart of the console app. |
@fabiocav - I had this happen with a timer triggered continuous webjob (same sdk/repo, same behavior) I was using to test app insights snapshot debugging. Make a .net framework webjob, add the timer trigger to the function so it fires every minute. In the function throw an exception when the current minute is even. To see how this affects app insights, wrap the function body in a try/catch and call the telemetry clients capture method for exceptions (not in front of a PC for a few days, sorry for lack of syntax), then rethrow the ex so the invocation can report failure correctly. Without swallowing the ex in the function, the telemetry client doesn't have enough time to capture and transfer the exception and snapshot debugging info before the process exiting. The same behavior should be present in an Azure function, at least it was when I was trying to (unsuccessfully, see the end of Azure/azure-functions-host#911) use them as webjob replacement a few weeks ago. |
@fabiocav - I cannot reveal the code that exhibited the issue and have tried to replicate it in a more simple repository. |
As a Function Developer
In order to monitor failures
I need to exit a function with different exit codes
and to control whether a failing message is retried or dead-lettered
Expected behavior
Permanent Failure
Actual behavior
Known workarounds
No known workarounds.
The text was updated successfully, but these errors were encountered: