[FA-misc] Initial MassTransit implementation seems to work
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using FictionArchive.Service.Shared.Services.EventBus;
|
||||
using MassTransit;
|
||||
using Newtonsoft.Json;
|
||||
using Quartz;
|
||||
|
||||
@@ -6,18 +6,18 @@ namespace FictionArchive.Service.SchedulerService.Models.JobTemplates;
|
||||
|
||||
public class EventJobTemplate : IJob
|
||||
{
|
||||
private readonly IEventBus _eventBus;
|
||||
private readonly IBus _bus;
|
||||
private readonly ILogger<EventJobTemplate> _logger;
|
||||
|
||||
public const string EventTypeParameter = "RoutingKey";
|
||||
public const string EventDataParameter = "MessageData";
|
||||
|
||||
public EventJobTemplate(IEventBus eventBus, ILogger<EventJobTemplate> logger)
|
||||
|
||||
public EventJobTemplate(IBus bus, ILogger<EventJobTemplate> logger)
|
||||
{
|
||||
_eventBus = eventBus;
|
||||
_bus = bus;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
@@ -25,7 +25,7 @@ public class EventJobTemplate : IJob
|
||||
var eventData = context.MergedJobDataMap.GetString(EventDataParameter);
|
||||
var eventType = context.MergedJobDataMap.GetString(EventTypeParameter);
|
||||
var eventObject = JsonConvert.DeserializeObject(eventData);
|
||||
await _eventBus.Publish(eventObject, eventType);
|
||||
await _bus.Publish(eventObject);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@ using FictionArchive.Service.SchedulerService.GraphQL;
|
||||
using FictionArchive.Service.SchedulerService.Services;
|
||||
using FictionArchive.Service.Shared;
|
||||
using FictionArchive.Service.Shared.Extensions;
|
||||
using FictionArchive.Service.Shared.Services.EventBus.Implementations;
|
||||
using Quartz;
|
||||
using Quartz.Impl.AdoJobStore;
|
||||
|
||||
@@ -38,10 +37,7 @@ public class Program
|
||||
|
||||
if (!isSchemaExport)
|
||||
{
|
||||
builder.Services.AddRabbitMQ(opt =>
|
||||
{
|
||||
builder.Configuration.GetSection("RabbitMQ").Bind(opt);
|
||||
});
|
||||
builder.Services.AddFictionArchiveMassTransit(builder.Configuration);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Data;
|
||||
using FictionArchive.Service.SchedulerService.Models;
|
||||
using FictionArchive.Service.SchedulerService.Models.JobTemplates;
|
||||
using FictionArchive.Service.Shared.Services.EventBus;
|
||||
using Quartz;
|
||||
using Quartz.Impl.Matchers;
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning"
|
||||
}
|
||||
},
|
||||
"RabbitMQ": {
|
||||
|
||||
Reference in New Issue
Block a user