Hi,
I’m wondering if it’s possible to set a name/text on a background job? Having 1000+ successful SendOrder() is nice but isn’t very useful when suddenly you have 2 SendOrder() that has failed.
I would like to have a string like “Send order #1202 to warehouse” for the background job instead of the actual method name. That way it would be a lot easier to check what went wrong.
Sincerely
David Sinclair
Succeeded jobs and failed jobs are already being shown on different pages. In your case, the failed jobs page will contain only two failed jobs, so you can easily debug them. Can you show the screenshot of a dashboard page that makes you unhappy?
Yes I’m fully aware of that. It’s just that it’s missing context and information that is relevant. I would like to have the possibility to set a text like this:
BackgroundJob.Enqueue(() => OrderService.CopyOrderToLevel4(orderId), string.Format(“Send order #{0} to warehouse”, orderId));
So I would have this instead -> http://i.imgur.com/fOVxOpO.jpg
That information should replace the method called. If I want more information about the job I should be able to dig into it and see the method being called and stacktrace etc, having a context when debugging is very useful.
I told you about page separation only because I can’t understand the following sentence:
Having 1000+ successful SendOrder() is nice but isn’t very useful when suddenly you have 2 SendOrder() that has failed.
Nevertheless I agree that textual method representation makes debugging simpler. Display name relates exactly to the calling method, so this feature can be implemented with DisplayNameAttribute
:
[DisplayName("Send order #{0} to warehouse")]
public void CopyOrderToLevel4(int orderId)
{
// Processing
}
Positional display name arguments can be substituted from method arguments. Job creation code remains simple:
BackgroundJob.Enqueue<IOrderService>(x => x.SendOrderToLevel4(orderId));
What do you think?
1 Like
Sure it sounds like a way to handle it. But how do I pass the parameter to the attribute?
Positional argument values will be substituted automatically with the background method call argument values:
String.Format(attribute.DisplayName, job.Arguments);
Awesome, that solves my problem perfectly.
1 Like