Releases: HangfireIO/Hangfire
0.6.2
0.6
What's new?
New Client API
Brand new Client API, based on lambda expressions. With this change, you don't even need to define custom job classes. You are able to invoke your existing methods asynchronously while maintaining persistence and transparency.
Two types of methods are supported: static and instance. Static methods will be simply called on the server side (without instance activation). To call instance methods, server will create an instance of the method's class first using the JobActivator
class.
public class CommentController : Controller
{
/* Other actions */
public ActionResult PostComment(string text)
{
var id = CommentService.Create(User, text);
// Static method
BackgroundJob.Enqueue(() => CheckForSpam(id));
// Instance method
BackgroundJob.Enqueue<CommentController>(x => x.SendToModerator(id));
return RedirectToAction(/* Some action */);
}
[NonAction]
public void SendToModerator(int commentId)
{
/* Implementation logic */
}
public static void CheckForSpam(int commentId)
{
/* Implementation logic (Akismet, etc.) */
}
}
Breaking changes
- Lifecycle of the
JobActivator
class has been changed. Use theJobActivator.SetCurrent
method to change it. - The signature of the
JobActivator.ActivateJob
method was changed. It now returns an instance ofobject
instead of an instance of theBackgroundJob
class. - The
JobDescriptor
class was removed. You can see all its properties in the*Context
classes. - The signature of all filter interfaces was changed. Affected
IStateChangingFilter
,IStateChangedFilter
,IClientFilter
,IServerFilter
. - The signature of
JobState
methods was changed also.
You'll need to change a bit your JobActivator
-based and JobFilterAttribute
-based classes.
Transition to the new API
The structure of those jobs, that were created with the new API, was changed. Since new API is more flexible, the old one will be deleted to not to confuse new users with several methods of doing the same things. This version does not contain breaking changes related to the Client API, but it was made obsolete and its usage is prohibited.
To make sure that the storage does not contain jobs in the old format, the transition to the new API will be implemented in two stages.
v0.7
: Remove thePerform
class to prohibit the use of the Old Client API. After removal of thePerform
class, you'll need to convert your existing job classes to correspond to the new API. If your storage is still contains old jobs, they will be processed anyway.Before v1.0
: Remove theBackgroundJob.Perform
method. All old jobs will be failed during their processing. You'll need to ensure that all old jobs were processing before proceeding to the version 1.0.
0.5
This is the first public release. Please, see the Getting Started guide.