Mq Consumer
This commit is contained in:
39
PARR.GeneratorTemplates/GeneratorTemplate.cs
Normal file
39
PARR.GeneratorTemplates/GeneratorTemplate.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.GeneratorTemplates.Settings;
|
||||
|
||||
namespace PARR.GeneratorTemplates
|
||||
{
|
||||
internal class GeneratorTemplate : IGeneratorTemplate
|
||||
{
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IMqService mqService;
|
||||
private readonly ILogger<GeneratorTemplate> logger;
|
||||
|
||||
public GeneratorTemplate(
|
||||
MqSettings mqSettings,
|
||||
IMqService mqService,
|
||||
ILogger<GeneratorTemplate> logger
|
||||
)
|
||||
{
|
||||
this.mqSettings = mqSettings;
|
||||
this.mqService = mqService;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
mqService.InitConsumer(mqSettings);
|
||||
|
||||
mqService.Received += (msg) =>
|
||||
{
|
||||
logger.LogInformation($"Привет откуда надо!!! ${msg}");
|
||||
};
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PARR.BLL;
|
||||
using PARR.DAL;
|
||||
using PARR.GeneratorTemplates.Settings;
|
||||
|
||||
namespace PARR.GeneratorTemplates
|
||||
{
|
||||
public static class GeneratorTemplateInstaller
|
||||
{
|
||||
//public static void InstallGeneratorTemplateServices(this IServiceCollection services, IConfiguration configuration)
|
||||
//{
|
||||
//1
|
||||
public static void InstallGeneratorTemplateServices(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.InstallDalServices(configuration);
|
||||
services.InstallBllServices(configuration);
|
||||
|
||||
var mqSettings = new MqSettings();
|
||||
configuration.GetSection(nameof(MqSettings)).Bind(mqSettings);
|
||||
services.AddSingleton(mqSettings);
|
||||
|
||||
//add other services
|
||||
services.AddTransient<IGeneratorTemplate, GeneratorTemplate>();
|
||||
}
|
||||
|
||||
//2
|
||||
public static IConfigurationBuilder AddGeneratorTemplateConfigurations(this IConfigurationBuilder builder, IServiceCollection services)
|
||||
{
|
||||
builder.AddDalConfigurations(services);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
//3
|
||||
public static void AddGeneratorTemplateSettings(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddDallSettings(configuration);
|
||||
}
|
||||
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
8
PARR.GeneratorTemplates/IGeneratorTemplate.cs
Normal file
8
PARR.GeneratorTemplates/IGeneratorTemplate.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace PARR.GeneratorTemplates
|
||||
{
|
||||
public interface IGeneratorTemplate
|
||||
{
|
||||
void Start();
|
||||
void Stop();
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,9 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PARR.BLL\PARR.BLL.csproj" />
|
||||
<ProjectReference Include="..\PARR.DAL\PARR.DAL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
12
PARR.GeneratorTemplates/Settings/MqSettings.cs
Normal file
12
PARR.GeneratorTemplates/Settings/MqSettings.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using PARR.BLL.Contracts.Interfaces;
|
||||
|
||||
namespace PARR.GeneratorTemplates.Settings
|
||||
{
|
||||
internal class MqSettings : IMqSettings
|
||||
{
|
||||
public string HostName { get; set; } = string.Empty;
|
||||
public string QueueName { get; set; } = string.Empty;
|
||||
public string User { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user