• Stars
    star
    566
  • Rank 78,774 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

httpjob for Hangfire,restful api for Hangfire,job调度与业务分离

Hangfire.HttpJob for .netcore

Hangfire.HttpJob for Hangfire

  1. add delay background job by [http post] or on dashbord

  2. add recurring job by [http post] or on dashbord

  3. search job by jobname on dashbord

  4. stop or start job on dashbord

  5. cron generator on dashbord

  6. use Hangfire.HttpJob.Agent extention to quick develop job program

    6.1 Make your webjob very convenient to support scheduling execution

    6.2 Visualizing the execution process of webjob by logs and progress on hangfire dashbord

    6.3 Variety of webjob types with different life cycles

    6.3.1 Singleton

    6.3.2 Transient

    6.3.3 Hang up until stop command

wiki

00.QickStart DockerQuickStart

01.how to create backgroud httpjob

02.how to create recurringHttpJob

03.how to use HttpJob.Agent

04.how to use in sqlserver

05.how to config mail service to report job result

https://github.com/yuzd/Hangfire.HttpJob/wiki

Installation

This library is available as a NuGet Package:

Install-Package Hangfire.HttpJob

Install-Package Hangfire.HttpJob.Agent

Install-Package Hangfire.HttpJob.Client

Usage

	//StartUp.cs
 
	public virtual void ConfigureServices(IServiceCollection services)
	{
		services.AddHangfire(Configuration);//Configuration是下面的方法
	}

	private void Configuration(IGlobalConfiguration globalConfiguration)
	{
		globalConfiguration.UseStorage(
				new MySqlStorage(
					"Server=localhost;Port=3306;Database=hangfire;Uid=root;Pwd=123456;charset=utf8;SslMode=none;Allow User Variables=True",
					new MySqlStorageOptions
					{
						TransactionIsolationLevel = IsolationLevel.ReadCommitted,
						QueuePollInterval = TimeSpan.FromSeconds(15),
						JobExpirationCheckInterval = TimeSpan.FromHours(1),
						CountersAggregateInterval = TimeSpan.FromMinutes(5),
						PrepareSchemaIfNecessary = false,
						DashboardJobListLimit = 50000,
						TransactionTimeout = TimeSpan.FromMinutes(1),
					}))
			.UseConsole()
			.UseHangfireHttpJob();
	}

	public void Configure(IApplicationBuilder app)
	{
		app.UseHangfireServer();
		app.UseHangfireDashboard("/hangfire",new DashboardOptions
		{
			Authorization = new[] { new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions
			{
				RequireSsl = false,
				SslRedirect = false,
				LoginCaseSensitive = true,
				Users = new []
				{
					new BasicAuthAuthorizationUser
					{
						Login = "admin",
						PasswordClear =  "test"
					} 
				}

			}) }
		});
	}

add Hangfire HttpJob by client

    Install-Package Hangfire.HttpJob.Client

    var serverUrl = "http://localhost:5000/job";
    var result = HangfireJobClient.AddBackgroundJob(serverUrl, new BackgroundJob
    {
	JobName = "测试api",
	Method = "Get",
	Url = "http://localhost:5000/testaaa",
	Mail = new List<string> {"[email protected]"},
	SendSucMail = true,
	DelayFromMinutes = 1
    }, new HangfireServerPostOption
    {
	BasicUserName = "admin",
	BasicPassword = "test"
    });
    
    var result = HangfireJobClient.AddRecurringJob(serverUrl, new RecurringJob()
    {
	JobName = "测试5点40执行",
	Method = "Post",
	Data = new {name = "aaa",age = 10},
	Url = "http://localhost:5000/testpost",
	Mail = new List<string> { "[email protected]" },
	SendSucMail = true,
	Cron = "40 17 * * *"
    }, new HangfireServerPostOption
    {
	BasicUserName = "admin",
	BasicPassword = "test"
    });

How to add Hangfire.HttpJob by restful api

1.add backgroundjob

url:http://{hangfireserver}/hangfire/httpjob?op=backgroundjob
method:post
data:
{
  "Method": "POST",
  "ContentType": "application/json",
  "Url": "http://XXXXXXX",
  "DelayFromMinutes": 1,
  "Data": "{\"userName\":\"test\"}",
  "Timeout": 5000,
  "BasicUserName": "",// 如果你希望hangfire执行http的时候带basic认证的话 就设置这2个参数
  "BasicPassword": "",
  "JobName": "test_backgroundjob"
}

2.add recurringjob

url:http://{hangfireserver}/hangfire/httpjob?op=recurringjob
method:post
data:
{
  "Method": "POST",
  "ContentType": "application/json",
  "Url": "http://XXXXXXX",
  "Data": "{\"userName\":\"test\"}",
  "Timeout": 5000,
  "Corn": "0 12 * */2",
  "BasicUserName": "",// 如果你希望hangfire执行http的时候带basic认证的话 就设置这2个参数
  "BasicPassword": "",
  "JobName": "test_recurringjob"
}

How to add Hangfire.HttpJob in Dashbord

image image image image image image image

Email notify

image

Thanks for the Rider IDE provided by JetBrains

More Repositories

1

AntDeploy

Tools to deploy applications to remote server(iis,windowsService,linuxService,docker) support netframework and dotnetcore,support rollback and increment deploy
C#
877
star
2

AntData.ORM

特色:vs插件或者t4一键生成entity 支持配置非物理外键。分离linq转sql引擎(原生linq非扩展)和执行dal功能,支持异步,支持netcore2.0
C#
434
star
3

AntDeployAgent

Tools to deploy applications to remote server(iis,windowsService,docker) support netframwork and dotnetcore,support rollback and increment deploy
340
star
4

AntMgr

netcore+vue mvc role management 快速开发系统(菜单,角色,权限[精确到按钮])
JavaScript
295
star
5

coding.net

coding.net project webhook plugin for jenkins
Java
219
star
6

Hangfire.Core.Extend

在1.6.5基础上给dashbord增加了搜索功能,增加在dashbord上手动添加job,提供对外SDK添加job
C#
208
star
7

Autofac.Annotation

DI容器,依赖注入,AOP,动态代理等用注解来load autofac 摆脱代码或者xml配置和java的spring的注解注入一样的体验
C#
194
star
8

Swashbuckle

Swashbuckle自定义修改 汉化 使用jsonedior schema校验
JavaScript
194
star
9

DingtalkChatbotSdk

钉钉群机器人(.net跨平台)
C#
185
star
10

swagger2pdf

ant soa框架的swagger api文档生成(html or pdf)
JavaScript
185
star
11

OwinDog

Owin Web Server(base on libuv) for asp.net or netcore
C#
121
star
12

microsoft_ai

人工智能实战微信小程序demo
JavaScript
114
star
13

HttpClientFactory

safe HttpClient For netcore And netframework
C#
71
star
14

wechatmac

微信mac协议机器人
Objective-C
69
star
15

Hangfire.Dashboard.BasicAuthorization

Hangfire.Dashboard.BasicAuthorization for .netcore
C#
44
star
16

CanalSync

canal middleware for netcore
C#
22
star
17

Spa

单页面应用容器,netcore前后端分离,前端快速部署&回滚,会js就能写服务端脚本方案,用spa前端容器会js就是可以无所不能
JavaScript
21
star
18

ktormgen

dbmodels code gen for ktorm
Kotlin
17
star
19

maui_chatgpt

maui study
C#
17
star
20

ja3-csharp

tls指纹http2指纹获取中间件(反爬虫) https://kawayiyi.com/tls
C#
15
star
21

WindowsExplorerExtensions

动态配置右键菜单
C#
11
star
22

OpenQA.Selenium.Chrome.Fiddler

Extensions for ChromeOptions (Selenium Driver)支持配置拦截或转发指定请求(正则)
C#
10
star
23

AppendFileVersion

VSIX 统一修改 html or cshtml 中的 css标签和script标签添加统一版本号 来防止缓存
C#
9
star
24

Exporter

export csv/json/list/datatable to excel
C#
8
star
25

Spring.EL

Spring.EL on csharp
C#
7
star
26

jib

Build container images for your any applications.
6
star
27

Hangfire.Mysql.Extend

配合修改增加dashbord的搜索功能并修改了配合使用hangfire.console的Bug
C#
6
star
28

FastExpressionEngine

字符串解析表达式引擎
C#
4
star
29

ace_clickhouse

ace editor for clickhouse with autocomplete
JavaScript
3
star
30

yuzd

my
3
star
31

protocodegen

proto3 codegen plugin for idea
Kotlin
2
star
32

asyncawait_helper

project for convert async await by csharp nomarl code
C#
1
star
33

springboot_staticmock

Java
1
star
34

Ant.soa

ant soa framework
1
star
35

Autofac.Configuration.Core

Autofac.Configuration.Core With Interceptors
C#
1
star