{"id":24475522,"url":"https://github.com/milvasoft/milvasoft.messaging","last_synced_at":"2025-09-03T15:37:55.898Z","repository":{"id":124307867,"uuid":"416098192","full_name":"Milvasoft/Milvasoft.Messaging","owner":"Milvasoft","description":"Provides message broker and service bus operations.","archived":false,"fork":false,"pushed_at":"2025-02-02T15:12:20.000Z","size":139,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-23T00:39:12.023Z","etag":null,"topics":["masstransit","message-queue","messagebroker","rabbitmq","servicebus"],"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/Milvasoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2021-10-11T21:54:38.000Z","updated_at":"2025-06-10T11:48:59.000Z","dependencies_parsed_at":"2025-04-13T13:07:36.593Z","dependency_job_id":"a6e49f0c-5e29-48b2-a07e-9d64be2d7532","html_url":"https://github.com/Milvasoft/Milvasoft.Messaging","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/Milvasoft/Milvasoft.Messaging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milvasoft%2FMilvasoft.Messaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milvasoft%2FMilvasoft.Messaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milvasoft%2FMilvasoft.Messaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milvasoft%2FMilvasoft.Messaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Milvasoft","download_url":"https://codeload.github.com/Milvasoft/Milvasoft.Messaging/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milvasoft%2FMilvasoft.Messaging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273467254,"owners_count":25111129,"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-03T02:00:09.631Z","response_time":76,"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":["masstransit","message-queue","messagebroker","rabbitmq","servicebus"],"created_at":"2025-01-21T09:15:09.487Z","updated_at":"2025-09-03T15:37:55.888Z","avatar_url":"https://github.com/Milvasoft.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Provides models and configurations for message broker and service bus operations. With [MassTransit](https://github.com/MassTransit/MassTransit)\n  \n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Milvasoft/Milvasoft/blob/master/LICENSE)  [![NuGet](https://img.shields.io/nuget/v/Milvasoft.Templates.Web.Ef)](https://www.nuget.org/packages/Milvasoft.Helpers/)   [![NuGet](https://img.shields.io/nuget/dt/Milvasoft.Messaging)](https://www.nuget.org/packages/Milvasoft.Messaging) \n\n# Requirements\nOne of the runtime environment is required from below\n* .NET 9.0\n* RabbitMQ\n\n# Installation\n\nFor now you'll need to install following libraries:\n\n* To install Milvasoft.Messaging, run the following command in the Package Manager Console\n```\nInstall-Package Milvasoft.Messaging\n```\n Or you can download the latest .dll from [Github](https://github.com/Milvasoft/Milvasoft.Messaging)\n\nBefore using this library install RabbitMQ to your machine. You can run RabbitMQ easily with [Docker](https://hub.docker.com/_/rabbitmq).\n\n# Milvasoft.Messaging Usage\n\nIn Startup.cs;\n\n```csharp 1\n\n...\n\t    \n services.AddMilvaMessaging(cfg =\u003e\n {\n     cfg.RabbitMqUri = \"rabbitmq://localhost:5672/\";\n     cfg.UserName = \"admin\";\n     cfg.Password = \"yourstrongpassword\";\n });\n\n...\n\n```\n\nFor send mail command to RabbitMQ, you can use ready made publisher;\n\n```csharp 1\n\n...\n\nvar commandSender = (ICommandSender)httpContext.RequestServices.GetService(typeof(ICommandSender));\n\t    \nawait commandSender.PublishSendMailCommandAsync(new SendMailCommand\n{\n    From = \"sender@yourdomain.com\",\n    FromPassword = \"yourstrongpassword\",\n    Port = 587,\n    SmtpHost = \"mail.yourdomain.com\",\n    To = \"reciever@somedomain.com\",\n    Subject = \"Test Mail\",\n    HtmlBody = htmlContent\n});\n\n...\n\n```\n\nOr you can publish command manually.\n\nFor recieve and process send mail, you must write consumer project. This can be console application, web api or etc. We will create console application for this tutorial.\n\nThe console project you have created needs to be constantly up, so that it listens to the RabbitMQ queue and performs the operation when a new command arrives. For this, your main method must be as follows in Program.cs;\n\n```csharp 1\n\nstatic async Task Main(string[] args)\n{\n    Console.Title = \"Milvasoft.MailSenderMicroService\";\n\n    var builder = new HostBuilder().ConfigureServices((hostContext, services) =\u003e\n    {\n        services.AddHostedService\u003cMailHostedService\u003e();\n\n        var busConfigurator = new RabbitMqBusConfigurator(new RabbitMqConfiguration\n        {\n            RabbitMqUri = \"rabbitmq://localhost:5672/\",\n            UserName = \"admin\",\n            Password = \"yourstrongpassword\",\n        });\n\n        var bus = busConfigurator.CreateBus(cfg =\u003e\n        {            \n            cfg.ReceiveEndpoint(RabbitMqConstants.MailServiceQueueName, e =\u003e\n            {\n                e.Consumer\u003cSendMailCommandConsumer\u003e();\n                \n                //You can configure your recieve endpoint according to your needs in MassTransit.\n                e.UseMessageRetry(r =\u003e r.Interval(2, 30000));\n                e.UseRateLimit(30, TimeSpan.FromMinutes(1));\n            });\n        });\n\n        services.AddSingleton(bus);\n    });\n\n    await builder.RunConsoleAsync();\n}\n\n```\n\nCreate new class which named MailHostedService. This will provide your console app is constantly up.\n\n```csharp 1\n\nusing MassTransit;\nusing Microsoft.Extensions.Hosting;\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace Milvasoft.Consumers.Mails\n{\n    public class MailHostedService : IHostedService\n    {\n        private readonly IBusControl _bus;\n\n        /// \u003csummary\u003e\n        /// Initializes new instance of \u003csee cref=\"MailHostedService\"/\u003e.\n        /// \u003c/summary\u003e\n        /// \u003cparam name=\"bus\"\u003e\u003c/param\u003e\n        public MailHostedService(IBusControl bus)\n        {\n            _bus = bus;\n        }\n\n        public async Task StartAsync(CancellationToken cancellationToken)\n        {\n            await Console.Out.WriteLineAsync(\"Listening for Email Service commands/events...\");\n\n            await _bus.StartAsync(cancellationToken).ConfigureAwait(false);\n        }\n\n        public Task StopAsync(CancellationToken cancellationToken)\n        {\n            Console.WriteLine(\"Email Service stopping.\");\n\n            return _bus.StopAsync(cancellationToken);\n        }\n    }\n}\n\n```\n\nCreate class which named SendMailCommandConsumer. This class will run the incoming commands when a new command arrives in the listening queue.\n\n\n```csharp 1\n\nusing MassTransit;\nusing Milvasoft.Messaging.RabbitMq.Commands;\nusing System;\nusing System.Net;\nusing System.Net.Mail;\nusing System.Threading.Tasks;\n\nnamespace Milvasoft.Consumers.Mails\n{\n    public class SendMailCommandConsumer : IConsumer\u003cISendMailCommand\u003e\n    {\n        public async Task Consume(ConsumeContext\u003cISendMailCommand\u003e context)\n        {\n            try\n            {\n                using var mailMessage = new MailMessage(context.Message.From,\n                                                        context.Message.To,\n                                                        context.Message.Subject,\n                                                        context.Message.HtmlBody)\n                {\n                    IsBodyHtml = true\n                };\n\n                using var smtpClient = new SmtpClient(context.Message.SmtpHost, context.Message.Port);\n\n                smtpClient.Credentials = new NetworkCredential(context.Message.From, context.Message.FromPassword);\n\n                await smtpClient.SendMailAsync(mailMessage).ConfigureAwait(false);\n            }\n            catch (Exception ex)\n            {\n                await Console.Out.WriteLineAsync(\"An error occured when sending mail.\");\n            }\n        }\n    }\n}\n\n```\n\nIn this way, you can perform operations independent of your project with RabbitMQ. The main purpose of the library is to combine the models that need to be shared between the publisher and the consumer projects and to provide an abstraction for doing these operations. \n\n### You can contribute to the improve of this library by adding more various operations like mail sending.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilvasoft%2Fmilvasoft.messaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilvasoft%2Fmilvasoft.messaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilvasoft%2Fmilvasoft.messaging/lists"}