45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using IM_API.Application.EventHandlers.FriendAddHandler;
|
|
using IM_API.Application.EventHandlers.MessageCreatedHandler;
|
|
using IM_API.Application.EventHandlers.RequestFriendHandler;
|
|
using MassTransit;
|
|
|
|
namespace IM_API.Configs
|
|
{
|
|
public static class MQConfig
|
|
{
|
|
public static IServiceCollection AddRabbitMQ(this IServiceCollection services, RabbitMqOptions options)
|
|
{
|
|
services.AddMassTransit(x =>
|
|
{
|
|
x.AddConsumer<ConversationEventHandler>();
|
|
x.AddConsumer<SignalREventHandler>();
|
|
x.AddConsumer<FriendAddDBHandler>();
|
|
x.AddConsumer<FriendAddSignalRHandler>();
|
|
x.AddConsumer<RequestFriendSignalRHandler>();
|
|
x.AddConsumer<FriendAddConversationHandler>();
|
|
|
|
x.UsingRabbitMq((ctx,cfg) =>
|
|
{
|
|
cfg.Host(options.Host, "/", h =>
|
|
{
|
|
h.Username(options.Username);
|
|
h.Password(options.Password);
|
|
});
|
|
cfg.ConfigureEndpoints(ctx);
|
|
});
|
|
});
|
|
|
|
|
|
return services;
|
|
}
|
|
}
|
|
|
|
public class RabbitMqOptions
|
|
{
|
|
public string Host { get; set; }
|
|
public int Port { get; set; }
|
|
public string Username { get; set; }
|
|
public string Password { get;set; }
|
|
}
|
|
}
|