{"id":21599469,"url":"https://github.com/sitholewb/subpub.hangfire","last_synced_at":"2026-06-18T16:32:30.161Z","repository":{"id":240800055,"uuid":"803498342","full_name":"SitholeWB/SubPub.Hangfire","owner":"SitholeWB","description":"Lets you create applications with event publishers and subscribers. Publishers communicate LOCALLY with subscribers by broadcasting events, Hangfire will process these events in the background via implemented handlers","archived":false,"fork":false,"pushed_at":"2024-06-02T10:59:52.000Z","size":1258,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T12:37:19.561Z","etag":null,"topics":["event-sourcing","hangfire","hangfire-extension","job-queue","job-scheduler","jobs","publisher","scheduler","sub-pub-event-topics","subscriber"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SitholeWB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-20T20:52:27.000Z","updated_at":"2024-06-02T10:59:55.000Z","dependencies_parsed_at":"2025-10-25T12:32:22.408Z","dependency_job_id":null,"html_url":"https://github.com/SitholeWB/SubPub.Hangfire","commit_stats":null,"previous_names":["sitholewb/hangfire.subpub","sitholewb/subpub.hangfire","sitholewb/events.hangfire.subpub"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SitholeWB/SubPub.Hangfire","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SitholeWB%2FSubPub.Hangfire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SitholeWB%2FSubPub.Hangfire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SitholeWB%2FSubPub.Hangfire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SitholeWB%2FSubPub.Hangfire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SitholeWB","download_url":"https://codeload.github.com/SitholeWB/SubPub.Hangfire/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SitholeWB%2FSubPub.Hangfire/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34499405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-sourcing","hangfire","hangfire-extension","job-queue","job-scheduler","jobs","publisher","scheduler","sub-pub-event-topics","subscriber"],"created_at":"2024-11-24T18:15:28.147Z","updated_at":"2026-06-18T16:32:30.141Z","avatar_url":"https://github.com/SitholeWB.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SubPub.Hangfire\n\nLets you create applications with event publishers and subscribers.\nPublishers communicate LOCALLY with subscribers by broadcasting events, Hangfire will process these events in the background via implemented handlers\n\n```nuget\nInstall-Package SubPub.Hangfire\n```\n\n```C#\n\n    public class RegisterEvent\n    {\n        public string Email { get; set; }\n        public DateTimeOffset Date { get; set; }\n    }\n    public class DuplicateRegisterEvent\n    {\n        public string Email { get; set; }\n        public DateTimeOffset Date { get; set; }\n    }\n\n    public class RegisterHandler : IHangfireEventHandler\u003cRegisterEvent\u003e\n    {\n        public Task RunAsync(RegisterEvent obj)\n        {\n            Console.WriteLine(\"**************START 1*********\");\n            Console.WriteLine($\"{obj.Email} from RegisterHandler\");\n            Console.WriteLine(\"**************END 1*********\");\n            return Task.CompletedTask;\n        }\n    }\n    public class Register2Handler : IHangfireEventHandler\u003cRegisterEvent\u003e\n    {\n        public Task RunAsync(RegisterEvent obj)\n        {\n            Console.WriteLine(\"**************START 1*********\");\n            Console.WriteLine($\"{obj.Email} from Register2Handler\");\n            Console.WriteLine(\"**************END 1*********\");\n            return Task.CompletedTask;\n        }\n    }\n\n    public class DuplicateRegisterHandler : IHangfireEventHandler\u003cDuplicateRegisterEvent\u003e\n    {\n        public Task RunAsync(DuplicateRegisterEvent obj)\n        {\n            Console.WriteLine(\"**************START 1*********\");\n            Console.WriteLine($\"{obj.Email} from DuplicateRegisterHandler\");\n            Console.WriteLine(\"**************END 1*********\");\n            return Task.CompletedTask;\n        }\n    }\n\n    [ApiController]\n    [Route(\"[controller]\")]\n    public class RegistrationController : ControllerBase\n    {\n        private readonly IHangfireEventHandlerContainer _hangfireEventHandlerContainer;\n\n        public RegistrationController(IHangfireEventHandlerContainer hangfireEventHandlerContainer)\n        {\n            _hangfireEventHandlerContainer = hangfireEventHandlerContainer;\n        }\n\n        [HttpPost]\n        public IActionResult Register(RegisterModel model)\n        {\n            var registerEvent = new RegisterEvent\n            {\n                Email = model.Email,\n                Date = DateTimeOffset.Now,\n            };\n            _hangfireEventHandlerContainer.Publish(registerEvent);\n            return Ok();\n        }\n\n        [HttpPost(\"schedule\")]\n        public IActionResult RegisterOnSchedule(RegisterModel model)\n        {\n            var registerEvent = new RegisterEvent\n            {\n                Email = model.Email,\n                Date = DateTimeOffset.Now,\n            };\n\n            var options = new HangfireJobOptions\n            {\n                HangfireJobType = HangfireJobType.Schedule,\n                TimeSpan = TimeSpan.FromSeconds(15)\n            };\n            _hangfireEventHandlerContainer.Publish(registerEvent, options);\n            return Ok();\n        }\n    }\n\n\n    //builder.Services.AddHangfire(x =\u003e x.UseSQLiteStorage());\n    //builder.Services.AddHangfireServer();\n\n    builder.Services.AddHangfireSubPub\u003cRegisterEvent\u003e()\n                    .Subscribe\u003cRegisterHandler\u003e()\n                    .Subscribe\u003cRegister2Handler\u003e();\n\n    builder.Services.AddHangfireSubPub\u003cDuplicateRegisterEvent\u003e()\n                    .Subscribe\u003cDuplicateRegisterHandler\u003e();\n\n```\n## Credit\nI got some of the other code ideas from this repository https://github.com/lamondlu/EventHandlerInSingleApplication\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitholewb%2Fsubpub.hangfire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsitholewb%2Fsubpub.hangfire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitholewb%2Fsubpub.hangfire/lists"}