添加es服务

This commit is contained in:
橙子
2021-11-09 18:55:11 +08:00
parent d9fe0895bc
commit bf9c86f7b7
2 changed files with 17 additions and 13 deletions

View File

@@ -49,16 +49,16 @@ namespace Yi.Framework.ElasticSearchProcessor
//<2F><><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>ɾ<EFBFBD>ģ<EFBFBD>es<65><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>ɾ<EFBFBD>ģ<EFBFBD>es<65><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD>
//switch (spuCQRSQueueModel.CQRSType) //switch (spuCQRSQueueModel.CQRSType)
//{ //{
//case (int)SPUCQRSQueueModelType.Insert: // case (int)SPUCQRSQueueModelType.Insert:
//case (int)SPUCQRSQueueModelType.Update: // case (int)SPUCQRSQueueModelType.Update:
// { // {
// Goods goods = this._ISearchService.GetGoodsBySpuId(spuCQRSQueueModel.SpuId); // Goods goods = this._ISearchService.GetGoodsBySpuId(spuCQRSQueueModel.SpuId);
// this._IElasticSearchService.InsertOrUpdata<Goods>(goods); // this._IElasticSearchService.InsertOrUpdata<Goods>(goods);
// break; // break;
// } // }
//case (int)SPUCQRSQueueModelType.Delete: // case (int)SPUCQRSQueueModelType.Delete:
// this._IElasticSearchService.Delete<Goods>(spuCQRSQueueModel.SpuId.ToString()); // this._IElasticSearchService.Delete<Goods>(spuCQRSQueueModel.SpuId.ToString());
// break; // break;
// default: // default:
// throw new Exception("wrong spuCQRSQueueModel.CQRSType"); // throw new Exception("wrong spuCQRSQueueModel.CQRSType");
//} //}

View File

@@ -13,7 +13,9 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Yi.Framework.Common.IOCOptions; using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Common.Models; using Yi.Framework.Common.Models;
using Yi.Framework.Common.QueueModel;
using Yi.Framework.Core; using Yi.Framework.Core;
using Yi.Framework.Interface;
namespace Yi.Framework.ElasticSearchProcessor namespace Yi.Framework.ElasticSearchProcessor
{ {
@@ -25,13 +27,15 @@ namespace Yi.Framework.ElasticSearchProcessor
private readonly ElasticSearchInvoker _elasticSearchInvoker; private readonly ElasticSearchInvoker _elasticSearchInvoker;
private readonly IOptionsMonitor<ElasticSearchOptions> _ElasticSearchOptions = null; private readonly IOptionsMonitor<ElasticSearchOptions> _ElasticSearchOptions = null;
public WarmupESIndexWorker(ILogger<WarmupESIndexWorker> logger, RabbitMQInvoker rabbitMQInvoker, IConfiguration configuration, ElasticSearchInvoker elasticSearchInvoker, IOptionsMonitor<ElasticSearchOptions> optionsMonitor) private readonly ISearchService _searchService;
public WarmupESIndexWorker(ILogger<WarmupESIndexWorker> logger, RabbitMQInvoker rabbitMQInvoker, IConfiguration configuration, ElasticSearchInvoker elasticSearchInvoker, IOptionsMonitor<ElasticSearchOptions> optionsMonitor, ISearchService searchService)
{ {
this._logger = logger; this._logger = logger;
this._RabbitMQInvoker = rabbitMQInvoker; this._RabbitMQInvoker = rabbitMQInvoker;
this._configuration = configuration; this._configuration = configuration;
this._elasticSearchInvoker = elasticSearchInvoker; this._elasticSearchInvoker = elasticSearchInvoker;
this._ElasticSearchOptions = optionsMonitor; this._ElasticSearchOptions = optionsMonitor;
this._searchService=searchService;
} }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) protected override async Task ExecuteAsync(CancellationToken stoppingToken)
@@ -44,14 +48,14 @@ namespace Yi.Framework.ElasticSearchProcessor
HttpClient _HttpClient = new HttpClient(); HttpClient _HttpClient = new HttpClient();
this._RabbitMQInvoker.RegistReciveAction(rabbitMQConsumerModel, message => this._RabbitMQInvoker.RegistReciveAction(rabbitMQConsumerModel, message =>
{ {
//SKUWarmupQueueModel skuWarmupQueueModel = JsonConvert.DeserializeObject<SKUWarmupQueueModel>(message); SKUWarmupQueueModel skuWarmupQueueModel = JsonConvert.DeserializeObject<SKUWarmupQueueModel>(message);
//<2F><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ģ<EFBFBD>͡<EFBFBD> //<2F><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ģ<EFBFBD>͡<EFBFBD>
#region <EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>Index---<EFBFBD>½<EFBFBD>Index---<EFBFBD>ٽ<EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #region <EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>Index---<EFBFBD>½<EFBFBD>Index---<EFBFBD>ٽ<EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{ {
try try
{ {
this._elasticSearchInvoker.DropIndex(this._ElasticSearchOptions.CurrentValue.IndexName); this._elasticSearchInvoker.DropIndex(this._ElasticSearchOptions.CurrentValue.IndexName);
//this._ISearchService.ImpDataBySpu(); this._searchService.ImpDataBySpu();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>es<65><73><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>es<65><73><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
this._logger.LogInformation($"{nameof(WarmupESIndexWorker)}.InitAll succeed"); this._logger.LogInformation($"{nameof(WarmupESIndexWorker)}.InitAll succeed");
return true; return true;