hangfire

开源分布式Job系统,调度与业务分离-如何创建周期性的HttpJob任务

久未见 提交于 2021-02-20 08:27:51
项目介绍: Hangfire:是一个开源的job调度系统,支持分布式JOB!! Hangfire.HttpJob 是我针对Hangfire开发的一个组件,该组件和Hangfire本身是独立的。可以独立更新Hangfire版本不影响! 该组件已被Hangfire官方采纳,在Hangfire官网可以查到: 开源地址: https://github.com/yuzd/Hangfire.HttpJob 该项目目的是: 剥离Job调度和业务 Hangfire.HttpJob究竟是干嘛的 传统使用Hangfire都是把JOb的处理逻辑代码写在和Hangfire的同一个工程! 缺点: 这样就耦合在了一起,如果业务线增大,会导致每个业务线的Job处理逻辑都得和Hangfire耦合在一起!发布的时候所有业务线Job都得暂停调度 而使用了Hangfire.HttpJob的话 就是把Hangfire的服务拓展成可以把Job的处理逻辑代码写在别的工程里面(以webapi的形式暴露给Hangfire去调度) 优点:这样就解耦了Hangfire和业务处理逻辑,业务job开发者可以忽略Hangfire的存在!不同的业务线分开不同的JobAgent可以分别部署,发布互不影响 Hangfire.HttpJob 是对Hangfire的一个扩展插件,利用Hangfire

MachineKeyDataProtector - Invalid link when confirmation email sent through background job

筅森魡賤 提交于 2021-02-10 12:28:12
问题 I've been pulling my hair out over this. Anytime a user registration email is sent out via my windows service (background task), I get an "Invalid link". My setup I'm using Hangfire as a windows service on our development server. This is where the problematic GenerateEmailConfirmationToken call is happening. It's in a completely different context, outside of the ASP.NET pipeline. So I have setup machineKey values to correspond with that in the web.config of the MVC application: In the app

话说Hangfire

淺唱寂寞╮ 提交于 2021-01-30 14:01:39
参考文档 www.hangfire.io github.com/HangfireIO/Hangfire .NET Core开源组件:后台任务利器之Hangfire 来源: oschina 链接: https://my.oschina.net/u/2912152/blog/1624928

.Net Core 3.1 SPA React Application doesn't serve Hangfire dashboard / Swagger on production

╄→гoц情女王★ 提交于 2021-01-29 07:22:50
问题 After installing the React app template from .NET Core 3.1 using dotnet new react the application works perfectly in Development and Production. The problem appears when trying to use Swagger or Hangfire dashboard endpoints. After the app is created I add the package reference for Hangfire and for practical purposes the memory storage: <PackageReference Include="Hangfire" Version="1.7.*" /> <PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" /> In Startup.cs : public void

.NET Core high memory usage in Docker (AWS ECS Fargate)

断了今生、忘了曾经 提交于 2021-01-28 03:14:02
问题 Here is a description of the application. I have a console application that runs Hangfire. There are several jobs that are recurring. One job, in particular, parses several large XML files. I deploy this console app as an AWS ECS Fargate ontainer. Every time the recurring job runs, the container memory usage keeps rising and rising until either the application becomes unresponsive or AWS kills the container. This is a 16GB container on ECS (big) and so it should be able to handle anything I

How do I schedule a job to be run at a specific date in Hangfire

拜拜、爱过 提交于 2021-01-27 07:22:57
问题 Hangfire.io supports making a CRON-like scheduling of recurring jobs. But how do I specify, that a specific job should be run once, at a specific date/time, e.g. that a job should be run June 4th 2016, at 16:22 - and only at that specific point in time? A similar way to ask the same question could be: how large a subset of the CRON expression described here, is supported by Hangfire? (The described CRON expression supports a "Year"-field which could be used). Also, do you think Hangfire is

How can I get a Hangfire job's end time?

ぐ巨炮叔叔 提交于 2021-01-07 06:31:45
问题 Given a Hangfire job's ID, how can I get the time at which the job finished running? I've tried the below, but the JobData class doesn't have a property for job end time. IStorageConnection connection = JobStorage.Current.GetConnection(); JobData jobData = connection.GetJobData(jobId); 回答1: I have had a similar requirement before. Here is a method I wrote to get the SucceededAt property using the name of the running method and the current PerformContext : public static DateTime?

How can I get a Hangfire job's end time?

左心房为你撑大大i 提交于 2021-01-07 06:30:46
问题 Given a Hangfire job's ID, how can I get the time at which the job finished running? I've tried the below, but the JobData class doesn't have a property for job end time. IStorageConnection connection = JobStorage.Current.GetConnection(); JobData jobData = connection.GetJobData(jobId); 回答1: I have had a similar requirement before. Here is a method I wrote to get the SucceededAt property using the name of the running method and the current PerformContext : public static DateTime?

Send messages via SignalR HubContext from method in project outside where Hubs are located

▼魔方 西西 提交于 2021-01-04 05:39:30
问题 I have a WebAPI project where the API, Service and Data layers are all in separate projects of the same solution. As part of a method in my Service project, I want to send a message to the connected clients of a hub in the API project. So far all of the examples I have found have everything in a single project and use a controller as the example sending a message via a hub. I've tried dependency injection (Autofac) however I am unable to get a reference to the MessageHub. [HubName("messages")

Hangfire - Prevent multiples of the same job being enqueued

拟墨画扇 提交于 2020-12-29 09:34:14
问题 Scenario: Job 1 is scheduled to run every 5 minutes, and takes ~1 minute to complete. A lot of work piles up and Job 1 takes 15 minutes to run. There are now three Job 1's being processed concurrently - I don't want this. How do I prevent Job 1 being added to the queue again if it is already there? Is there Hangfire setting, or do I need to poll job statuses manually? 回答1: You can use DisableConcurrentExecution attribute to prevent multiple executions of a method concurrently. Just put this