I’m not’ ready to blog about anything else yet, and it would be very strange to write only about Hangfire in a personal blog. New product blog contains all the required links, has the same header as other parts of official site and thus is more useful.
Logging was a very difficult thing to set-up in previous versions of Hangfire. Even if we omit tricky versioning issues, you had to install a separate logging adapter for your current logging library, with guessing the right one first (i.e. Common.Logging.NLog or Common.Logging.NLog20).
If your application uses other logging library or a custom one, just implement two simple interfaces:
And yes, Hangfire is no more have Common.Logging or Common.Logging.Core dependencies.
Debugging with Symbolsource
SymbolSource is a service which exposes PDB symbols so you can step through Hangfire code while debugging your application. There are a few things to configure before we can begin, see symbolsource.org for more information.
Within Visual Studio:
Go to Tools → Options → Debugger → General
Uncheck “Enable Just My Code (Managed only)”
Uncheck “Enable .NET Framework source stepping”
Check “Enable source server support”
Uncheck “Require source files to exactly match the original version”
As an ASP.NET developer, I always wanted to have something simple to handle scenarios where you need to build a long-running async task and show a loader to a user:
Nothing is being loaded here, don't let hypnotize yourself!
But every time I faced Windows Services, message queues and other difficult-to-understand problems and hard-to-maintain solutions, my head exploded into a billion pieces. At the same time I looked at Rails’ Sidekiq and wished to have a simple .NET alternative for background job processing. That is why I began to develop Hangfire (yep, just for the loader).
Slightly more than a year passed from the first commit and first version of Hangfire. This was my first open-source project that is being used more than in one organization, and it was an amazing experience for me to grow a project from scratch. I’m glad to see more and more people coming to the project and giving positive ratings and unvaluable feedback.
I want to keep Hangfire project as free as possible, but eliminate the most dangerous risk – the absence of time. There are many things to be done, including problems, new features, documentation, and I want to do them in a reasonable time.
Today, I’m introducing a new stage of Hangfire development – Hangfire Pro. It is a set of paid libraries that extend Hangfire functionality by providing features to improve performance and simplifying maintenance of background job processing in larger applications.
The Destiny of Hangfire.Redis
First, I’ll start with bad news – Hangfire.Redis package is moved to Hangfire Pro. This means that it became available only for Pro users and will be removed from public NuGet Gallery soon.
I understand that this step breaks your expectations, and I’m sorry for this. The source code will be available at Hangfire.Redis repository, but there will be no updates and official support.
Other existing parts of Hangfire will not be moved to the Pro version ever. Moreover, I’ll try to do the vice versa, by open-sourcing paid extensions in the future, when the project will be more stable.
Mostwanted features were implemented in the next version of Hangfire.Redis package. It now includes:
Compatibility with ServiceStack 4.0 libraries. It still uses ServiceStack v3 libraries, but ILMerge /internalize utility is being used to merge them into Hangfire.Redis assembly. So, you can use either Service v3 or v4 in your projects.
Configurable prefix for keys. You can use now the same database for different environments by setting corresponding prefix for keys in the RedisStorageOptions.Prefix property.
Hangfire Pro Today
Hangfire Pro already includes previously mentioned new version of Hangfire Redis package and a completely new Hangfire.PerformanceCounters package. The latter pushes internal metrics to Windows Performance Counters to proactively monitor issues with background job processing:
Hangfire Pro is available through the subscriptions you can buy at the official site. After purchasing a subscription, you will be able to do the following things:
Access to Hangfire Pro package binaries and sources on the private GitHub repository.
Access to priority and private support by dedicated e-mail (public forum discussions will be always free).
Use Hangfire under EULA for organizations that don’t want to use open-source licenses.
Hangfire Pro Roadmap
As I already said, Hangfire Pro will solve performance/usability/monitoring issues for larger web applications. Further work will be made in the following directions.
Batch jobs will help to build more complex workflows with Hangfire. They will give you the power of parallel processing and continuations, you can look at this code snippet:
Three first tasks will be executed in parallel, end the continuation will be invoked only after successful run of the first tasks.
Async Methods Support
As with async controllers in ASP.NET MVC, this feature enables you to improve overall throughput keeping the lowest number of workers in the pool. Instead of waiting for an outstanding I/O operation, they will be able to process other background jobs as well.
Hangfire has finally reached the 1.0 milestone! This means that public API is frozen and considered to be stable. Starting from now, the SemVer 2.0 specification will be used for versioning every package (but there may be exceptions, follow the README for each package).
I want to thank everyone who helped me to reach this milestone, without your participation I would not be able to finish the work. Special thanks:
@devmondo – for endless optimism that helped me a lot in difficult times.
The Cron class provides different easy to use methods and overloads to set up recurring jobs on a minutely, hourly, weekly, monthly and yearly basis. It is also possible to use more complex CRON expressions, since the NCrontab library is being used to perform scheduling logic.