68 lines
2.8 KiB
C#
68 lines
2.8 KiB
C#
using AutoMapper;
|
|
using IM_API.Application.EventHandlers.FriendAddHandler;
|
|
using IM_API.Application.EventHandlers.GroupInviteActionUpdateHandler;
|
|
using IM_API.Application.EventHandlers.GroupInviteHandler;
|
|
using IM_API.Application.EventHandlers.GroupJoinHandler;
|
|
using IM_API.Application.EventHandlers.GroupRequestHandler;
|
|
using IM_API.Application.EventHandlers.GroupRequestUpdateHandler;
|
|
using IM_API.Application.EventHandlers.MessageCreatedHandler;
|
|
using IM_API.Application.EventHandlers.RequestFriendHandler;
|
|
using IM_API.Application.EventHandlers.UploadEventHandler;
|
|
using IM_API.Configs.Options;
|
|
using IM_API.Domain.Events;
|
|
using MassTransit;
|
|
using MySqlConnector;
|
|
|
|
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.AddConsumer<MessageCreatedDbHandler>();
|
|
x.AddConsumer<GroupJoinConversationHandler>();
|
|
x.AddConsumer<GroupJoinDbHandler>();
|
|
x.AddConsumer<GroupJoinSignalrHandler>();
|
|
x.AddConsumer<GroupRequestSignalRHandler>();
|
|
x.AddConsumer<Application.EventHandlers.GroupRequestHandler.NextEventHandler>();
|
|
x.AddConsumer<Application.EventHandlers.GroupRequestUpdateHandler.NextEventHandler>();
|
|
x.AddConsumer<GroupInviteSignalRHandler>();
|
|
x.AddConsumer<RequestDbHandler>();
|
|
x.AddConsumer<SignalRHandler>();
|
|
x.AddConsumer<RequestUpdateSignalrHandler>();
|
|
x.AddConsumer<MergeEventHandler>();
|
|
x.UsingRabbitMq((ctx,cfg) =>
|
|
{
|
|
cfg.Host(options.Host, "/", h =>
|
|
{
|
|
h.Username(options.Username);
|
|
h.Password(options.Password);
|
|
});
|
|
cfg.ConfigureEndpoints(ctx);
|
|
cfg.UseMessageRetry(r =>
|
|
{
|
|
r.Handle<IOException>();
|
|
r.Handle<MySqlException>();
|
|
r.Ignore<AutoMapperMappingException>();
|
|
r.Exponential(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(2));
|
|
});
|
|
cfg.ConfigureEndpoints(ctx);
|
|
});
|
|
});
|
|
|
|
|
|
return services;
|
|
}
|
|
}
|
|
|
|
|
|
}
|