Reputation: 12374
I noticed this field in the Hangfire Dashboard for a succeeded job:
I would love to shove some data in there, to give me more information about what the job did.
How would I do that?
I have searched google, checked the Hangfire documentation etc, but with no luck - probably because "result" is a very tricky keyword to search for in this context.
Upvotes: 12
Views: 6913
Reputation: 303
To programmatically get returned value, use IMonitoringApi
.
E.g. Helper method to get List<TReturn>
:
List<TReturn> GetReturnedItems<TReturn>(string jobId)
{
IMonitoringApi jobMonitoringApi = JobStorage.Current.GetMonitoringApi();
JobDetailsDto job = jobMonitoringApi.JobDetails(jobId);
string resultSerialized = job.History[0].Data["Result"];
List<TReturn> returnedItems = JsonConvert.DeserializeObject<List<TReturn>>(resultSerialized);
return returnedItems;
}
Upvotes: 6
Reputation: 879
The "Result" field displays the output/result your method returns.
You can return a string or object and Hangfire will convert it to JSON.
Your "Result" field contains a serialization error, Hangfire is failing to serialize the returned object but without any code I cannot help you further.
Please see example screenshots below.
Upvotes: 14