RabbitMqModule 1.0.9
RabbitMqModule
RabbitMqModule, RabbitMQ ile mesajlaşma işlemlerini kolayca entegre edebilmeniz için yazılmış bir servis modülüdür. Modül, mesaj göndermek için kullanılan temel işlevselliği kapsar ve başka uygulamalarda kolayca yeniden kullanılabilir.
Bu modül, RabbitMQ servisinin bağlantı yönetimini ve mesaj gönderme işlemini bir arada sunar. SendMessage metodu ile belirli bir exchange, routing key ve message ile mesaj gönderilmesini sağlar.
Projeye Ekleme
Windows : %appdata%\NuGet\NuGet.Config Lİnux Veya Mac : ~/.nuget/NuGet/NuGet.Config
...
<packageSources>
...
<add key="localnuget.roboliza.com" value="http://172.16.33.42:5011/v3/index.json" protocolVersion="3" allowInsecureConnections="true" />
<add key="nuget.roboliza.com" value="https://nuget.roboliza.com/v3/index.json" protocolVersion="3" allowInsecureConnections="true" />
</packageSources>
Dockerfile Dosyasına Ekleme
RUN dotnet nuget add source http://172.16.33.42:5011/v3/index.json
RUN dotnet nuget add source https://nuget.roboliza.com/v3/index.json
RabbitMq Modülünü Dahil Etme
Program.cs
public void ConfigureServices(IServiceCollection services)
{
RabbitMqConfig rabbitMqConfig = new()
{
HostName = "HostName",
UserName = "UserName",
Password = "Password",
ServiceName = "serviceName",
ProvidedName = "providedName"
};
services.AddRabbitMqModule(rabbitMqConfig);
}
Kullanım
public class MessageSenderService
{
// Dependency Injection ile bu delegate, RabbitMQ servisinin SendMessage metodunu çağırabilmemizi sağlar
private readonly Func<string, string, object, Action<string, string, object>> _sendMessageFunc;
public MessageSenderService(Func<string, string, object, Action<string, string, object>> sendMessageFunc)
{
_sendMessageFunc = sendMessageFunc;
}
public void SendMessage(string exchange, string routingKey, object message)
{
var sendMessage = _sendMessageFunc(exchange, routingKey, message);
sendMessage(exchange, routingKey, message); // Mesajı gönder
}
}
No packages depend on RabbitMqModule.
.NET 6.0
- Microsoft.Extensions.DependencyInjection (>= 6.0.2)
- Newtonsoft.Json (>= 13.0.3)
- RabbitMQ.Client (>= 6.8.1)