{"id":17081490,"url":"https://github.com/benfoster/fabrik.simplebus","last_synced_at":"2025-09-02T04:09:02.421Z","repository":{"id":6370558,"uuid":"7607923","full_name":"benfoster/Fabrik.SimpleBus","owner":"benfoster","description":"A simple In-Process Message Bus for .NET","archived":false,"fork":false,"pushed_at":"2013-03-07T10:16:48.000Z","size":373,"stargazers_count":58,"open_issues_count":1,"forks_count":11,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-09-01T03:58:31.135Z","etag":null,"topics":[],"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/benfoster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-14T16:28:08.000Z","updated_at":"2025-02-18T07:59:59.000Z","dependencies_parsed_at":"2022-08-29T12:10:32.636Z","dependency_job_id":null,"html_url":"https://github.com/benfoster/Fabrik.SimpleBus","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/benfoster/Fabrik.SimpleBus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benfoster%2FFabrik.SimpleBus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benfoster%2FFabrik.SimpleBus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benfoster%2FFabrik.SimpleBus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benfoster%2FFabrik.SimpleBus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benfoster","download_url":"https://codeload.github.com/benfoster/Fabrik.SimpleBus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benfoster%2FFabrik.SimpleBus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273228087,"owners_count":25067720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"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":[],"created_at":"2024-10-14T12:53:17.792Z","updated_at":"2025-09-02T04:09:02.403Z","avatar_url":"https://github.com/benfoster.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fabrik.SimpleBus\r\n\r\n## Overview\r\n\r\nFabrik.SimpleBus is a simple in-process message bus written in C# that uses TPL Dataflow to provide asynchronous messaging capabilities.\r\n\r\nThis is useful when you are handling messages asynchronously or need to fire-and-forget.\r\n\r\n## Getting Started\r\n\r\n#### Creating a new message bus instance:\r\n\r\n\tIBus bus = new InProcessBus();\r\n\r\n#### Subscribing with a delegate\r\n\r\nBoth synchronous and asynchronous delegates are supported.\r\n\r\n    bus.Subscribe\u003cstring\u003e(message =\u003e Console.WriteLine(\"Received message: {0}\", message));\r\n    bus.Subscribe\u003cstring\u003e(async message =\u003e await WriteMessageAsync(message));\r\n\r\n#### Strongly typed message handlers\r\n\r\n    public class Message\r\n    {\r\n        public string Body { get; set; }\r\n    }\r\n\r\n    public class MessageHandler : IHandle\u003cMessage\u003e\r\n    {\r\n        public void Handle(Message message)\r\n        {\r\n            Console.WriteLine(\"{0} handled {1}\", this.GetType().Name, typeof(Message).Name);\r\n        }\r\n    }\r\n\r\n    public class AsyncMessageHandler : IHandleAsync\u003cMessage\u003e\r\n    {\r\n        public async Task HandleAsync(Message message, CancellationToken cancellationToken)\r\n        {\r\n            await Task.Delay(1000);\r\n            Console.WriteLine(\"{0} handled {1}\", this.GetType().Name, typeof(Message).Name);\r\n        }\r\n    }\r\n\r\n**Note: Messages are matched to handlers based on whether they are or implement the required message type. \r\nThis makes it possible to subscribe to all messages of a specific base class or interface.**\r\n\r\n#### Subscribing message handlers\r\n\r\nIn most cases you will want to initialize a handler *per message*, for example, you may need to construct the handler using your IoC tool.\r\n\r\n`IBus.Subscribe` provides overloads for passing in a `Func\u003cIHandle\u003e` and `Func\u003cIHandlAsync\u003e` for this purpose:\r\n\r\n    bus.Subscribe\u003cMessage\u003e(() =\u003e new MessageHandler());\r\n    bus.Subscribe\u003cMessage\u003e(() =\u003e new AsyncMessageHandler());\r\n\r\nUsing StructureMap we may do something like this:\r\n\r\n\tbus.Subscribe\u003cMessage\u003e(ObjectFactory.GetInstance\u003cMessageHandler\u003e);\r\n\r\n#### Unsubscribing\r\n\r\nThe `IBus.Subscribe` method returns a `Guid` subscription identifier. You can use this to unsubscribe at runtime:\r\n\r\n    var id = bus.Subscribe\u003cstring\u003e(message =\u003e Console.WriteLine(message));\r\n    bus.Unsubscribe(id);\r\n\r\nNote that unsubscribing a handler will not effect any messages currently being processed.\r\n\r\n#### Sending messages\r\n\r\n    bus.SendAsync(input).ContinueWith(task =\u003e Console.WriteLine(\"Enter another message\")).Wait();\r\n\r\n#### Cancelling Message Sending\r\n\r\nYou can cancel the processing of a sent message by passing a `CancellationToken`. \r\n\t\r\n\tbus.SendAsync(input, cancellationTokenSource.Token).Wait();\r\n\r\nWhen a cancellation request is received, no more message subscribers are invoked for the current message.\r\n\r\n## License\r\n\r\nLicensed under the MIT License.\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenfoster%2Ffabrik.simplebus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenfoster%2Ffabrik.simplebus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenfoster%2Ffabrik.simplebus/lists"}