{"id":16686810,"url":"https://github.com/jacqueskang/eventbus","last_synced_at":"2025-03-17T00:33:00.497Z","repository":{"id":29569615,"uuid":"122088084","full_name":"jacqueskang/EventBus","owner":"jacqueskang","description":"A .NET Core ultra lightweight in-memory event bus implementation.","archived":false,"fork":false,"pushed_at":"2022-05-28T14:59:15.000Z","size":57,"stargazers_count":83,"open_issues_count":3,"forks_count":15,"subscribers_count":8,"default_branch":"develop","last_synced_at":"2024-05-29T05:47:35.008Z","etag":null,"topics":["aws-sns","dotnet-core","event-driven","eventbus","inmemory","sns"],"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/jacqueskang.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}},"created_at":"2018-02-19T16:16:53.000Z","updated_at":"2024-05-19T15:39:51.000Z","dependencies_parsed_at":"2022-07-27T20:29:32.349Z","dependency_job_id":null,"html_url":"https://github.com/jacqueskang/EventBus","commit_stats":null,"previous_names":["jacqueskang/events"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacqueskang%2FEventBus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacqueskang%2FEventBus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacqueskang%2FEventBus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacqueskang%2FEventBus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacqueskang","download_url":"https://codeload.github.com/jacqueskang/EventBus/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835942,"owners_count":20355611,"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","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":["aws-sns","dotnet-core","event-driven","eventbus","inmemory","sns"],"created_at":"2024-10-12T15:06:55.547Z","updated_at":"2025-03-17T00:33:00.199Z","avatar_url":"https://github.com/jacqueskang.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JKang.EventBus\n\n.NET Core event bus implementation supporting:\n * In-memory event dispatching (publishing and subscription)\n * publishing event to Amazon SNS\n * publishing event to Amazon SQS\n\n## NuGet packages\n\n - [JKang.EventBus](https://www.nuget.org/packages/JKang.EventBus/)\n\n## Quick start:\n\n1. Create a console application with the following NuGet packages installed:\n```console\n\u003e Install-Package Microsoft.Extensions.DependencyInjection\n\u003e Install-Package JKang.EventBus\n```\n\n 2. Create an event class\n\n```csharp\n    public class MyEvent\n    {\n        public string Message { get; set; }\n    }\n```\n\n3. Optionally implement one or multiple handlers subscribing to the event\n\n```csharp\n    class MyEventHandler : IEventHandler\u003cMyEvent\u003e\n    {\n        public Task HandleEventAsync(MyEvent @event)\n        {\n            Console.WriteLine($\"Received message '{@event.Message}'\");\n            return Task.CompletedTask;\n        }\n    }\n```\n\n4. Configure and register event bus using Dependency Injection\n\n```csharp\n    static void Main(string[] args)\n    {\n        IServiceCollection services = new ServiceCollection();\n\n        services.AddEventBus(builder =\u003e\n        {\n            builder.AddInMemoryEventBus(subscriber =\u003e\n            {\n                subscriber.Subscribe\u003cMyEvent, MyEventHandler\u003e();\n                //subscriber.SubscribeAllHandledEvents\u003cMyEventHandler\u003e(); // other way\n            });\n        });\n    }\n```\n\n5. Publish an event\n\n```csharp\n    IServiceProvider serviceProvider = services.BuildServiceProvider();\n    using (IServiceScope scope = serviceProvider.CreateScope())\n    {\n        IEventPublisher eventPublisher = scope.ServiceProvider.GetRequiredService\u003cIEventPublisher\u003e();\n        eventPublisher.PublishEventAsync(new MyEvent { Message = \"Hello, event bus!\" }).Wait();\n    }\n```\n\n\n## Publish event to Amazon Simple Notification Service (SNS)\n\n1. Install NuGet package [JKang.EventBus.AmazonSns](https://www.nuget.org/packages/JKang.EventBus.AmazonSns/)\n\n2. Configure publishing events to AWS SNS\n\n```csharp\n        services.AddEventBus(builder =\u003e\n        {\n            builder\n                //.AddInMemoryEventBus() // uncomment to keep using in-memory event bus in the same time\n                .PublishToAmazonSns(x =\u003e x.Region = \"eu-west-3\");\n        });\n```\n\n3. Optionally It's possible to customize AWS SNS topic name using annotation\n\n```csharp\n    [AmazonSnsTopic(\"my-event\")]\n    public class MyEvent { }\n```\n\n\n\n## Publish event to Amazon Simple Queue Service (SQS)\n\n1. Install NuGet package [JKang.EventBus.AmazonSqs](https://www.nuget.org/packages/JKang.EventBus.AmazonSqs/)\n\n2. Configure publishing events to AWS SQS\n\n```csharp\n        services.AddEventBus(builder =\u003e\n        {\n            builder\n                //.AddInMemoryEventBus() // uncomment to keep using in-memory event bus in the same time\n                .PublishToAmazonSqs(options =\u003e\n                    {\n                        options.AccessKeyId = \"\";\n                        options.SecretAccessKey = \"\";\n                        options.DefaultQueueUrl = \"\";\n                        options.Region = \"us-east-1\";\n                    });\n        });\n```\n\n3. Optionally It's possible to customize AWS SQS queue url using annotation\n\n```csharp\n    [AmazonSqsQueue(\"https://sqs.ap-southeast-2.amazonaws.com/189107071895/youtube-demo\")]\n    public class MyEvent { }\n```\n\n\nAny contributions or comments are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacqueskang%2Feventbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacqueskang%2Feventbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacqueskang%2Feventbus/lists"}