managing tasks with hangfire
TRANSCRIPT
![Page 1: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/1.jpg)
REINVÉNTATE TU, NO LA RUEDA
GESTIÓN DE TAREAS CON HANGFIRE
![Page 2: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/2.jpg)
Sergio Navarro Pino
I work for NEC, in its Cloud Computing Centre of Competence
Sometimes I write some tweets ( @snavarropino )
I also have a blog…Not yet forgotten…
http://serginet.blogspot.com
![Page 3: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/3.jpg)
BACKGROUND TASKSBackground task are required in many developments…
think in an eCommerce solution that sells subscription services
• Invoice generation at the end of every billing period
• Monthly Reporting
• Automatic subscription renewal
• Regular Mailings
• Send an email due to an action
• Backgroung service provisioning
![Page 4: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/4.jpg)
BACKGROUND TASKSSorts of background tasks
• Fire & Forget
• Send an email due to an action
• Delayed
• Automatic subscription renewal
• Periodic & schedulled
• Invoice generation at the end of very billing period
How to?
![Page 5: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/5.jpg)
"Yo... he visto cosas que vosotros no creeríais: Atacar naves en llamas más allá de Orión. He visto rayos C brillar en la oscuridad cerca de la Puerta de Tannhäuser. Todos esos momentos se perderán... en el tiempo... como lágrimas en la lluvia. Es hora de morir" - Roy Batty
![Page 6: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/6.jpg)
AVALIABLE POSIBILITIES
• Azure Scheduler ( https://azure.microsoft.com/en-us/services/scheduler/ )
• Quartz.NET ( http://www.quartz-scheduler.net/ )
• HangFire! ( http://hangfire.io/ )
• Develop from scratch
![Page 7: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/7.jpg)
HANGFIRE ARCHITECTURE
• Fire & Forget Jobs
• Delayed Jobs
• Recurrent Jobs
All of them running in a background thread on same server or other one
ASP.NET Thread Pool safe!
![Page 8: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/8.jpg)
LAUNCHING TASKS
![Page 9: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/9.jpg)
LAUNCHING BATCHES
![Page 10: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/10.jpg)
CRON EXPRESSIONS?
![Page 11: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/11.jpg)
CONTINUING TASKS
![Page 12: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/12.jpg)
METHOD RESOLUTION
• STATICS ARE EASY…• BUT INSTANCE METHODS ARE ALSO SUPPORTED
By default, the Activator.CreateInstace method is being used, so only classes with default constructors are supported by default.
![Page 13: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/13.jpg)
HOSTING THE HANGFIRE SERVER
• IN ASP.NET • IN A DEDICATED SERVER (WIN SRV, CONSOLE APP, ETC…)
![Page 14: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/14.jpg)
![Page 15: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/15.jpg)
THE DASHBOARD
![Page 16: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/16.jpg)
![Page 17: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/17.jpg)
DISTRIBUTED TASK?
![Page 18: Managing tasks with Hangfire](https://reader036.vdocument.in/reader036/viewer/2022062823/587767701a28ab4e4f8b8015/html5/thumbnails/18.jpg)
RESOURCES• Source: https://github.com/snavarropino/Hangfire-samples
• Slides: http://www.slideshare.net/sergio_pino