防gank
This commit is contained in:
parent
cfb761a806
commit
6021e7c5d9
@ -3,7 +3,6 @@ using DotNetCore.CAP.Filter;
|
|||||||
using SJZY.Expand.ABP.Core;
|
using SJZY.Expand.ABP.Core;
|
||||||
using SJZY.Expand.ABP.Core.Logger;
|
using SJZY.Expand.ABP.Core.Logger;
|
||||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||||
using SJZY.Track.Domain.Consts;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Application.EventHandlers;
|
namespace SJZY.Track.Application.EventHandlers;
|
||||||
|
|
||||||
@ -18,8 +17,6 @@ public class CAPFilter : SubscribeFilter
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override Task OnSubscribeExecutingAsync(ExecutingContext context)
|
public override Task OnSubscribeExecutingAsync(ExecutingContext context)
|
||||||
{
|
{
|
||||||
if (context.DeliverMessage.Headers["cap-msg-name"] == GlobalConst.TrackRefreshSubscribe)
|
|
||||||
return Task.CompletedTask;
|
|
||||||
var argumentJsonStr = context.Arguments.ToJson();
|
var argumentJsonStr = context.Arguments.ToJson();
|
||||||
|
|
||||||
context.DeliverMessage.Headers["sjzy-receive-time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff");
|
context.DeliverMessage.Headers["sjzy-receive-time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff");
|
||||||
@ -31,8 +28,8 @@ public class CAPFilter : SubscribeFilter
|
|||||||
using (RedisHelper.Client.Lock("Filter:" + hash, 10))
|
using (RedisHelper.Client.Lock("Filter:" + hash, 10))
|
||||||
{
|
{
|
||||||
var isSkip = !string.IsNullOrEmpty(RedisHelper.Client.Get($"CapExcuteFilter:{hash}"));
|
var isSkip = !string.IsNullOrEmpty(RedisHelper.Client.Get($"CapExcuteFilter:{hash}"));
|
||||||
if (isSkip)
|
// if (isSkip)
|
||||||
throw new BusinessException(_ERROR_CODE, $"检测到重复消费,消费参数:{argumentJsonStr}");
|
// throw new BusinessException(_ERROR_CODE, $"检测到重复消费,消费参数:{argumentJsonStr}");
|
||||||
|
|
||||||
RedisHelper.Client.Set($"CapExcuteFilter:{hash}", 60 * 10,
|
RedisHelper.Client.Set($"CapExcuteFilter:{hash}", 60 * 10,
|
||||||
TimeSpan.FromHours(1).Seconds); // 1h内不允许一模一样的参数重复消费
|
TimeSpan.FromHours(1).Seconds); // 1h内不允许一模一样的参数重复消费
|
||||||
|
|||||||
@ -85,8 +85,11 @@ namespace SJZY.Track.Application
|
|||||||
configure.Password = configuration["RabbitMQ:Password"]!;
|
configure.Password = configuration["RabbitMQ:Password"]!;
|
||||||
configure.Port = configuration.GetValue<int>("RabbitMQ:Port");
|
configure.Port = configuration.GetValue<int>("RabbitMQ:Port");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
options.TopicNamePrefix = "v1";
|
||||||
|
options.SucceedMessageExpiredAfter = 6 * 60 * 60;
|
||||||
options.FailedRetryInterval = 60;
|
options.FailedRetryInterval = 60;
|
||||||
options.FailedRetryCount = 10;
|
options.FailedRetryCount = 3;
|
||||||
options.UseDashboard(dashboardOptions =>
|
options.UseDashboard(dashboardOptions =>
|
||||||
{
|
{
|
||||||
dashboardOptions.PathBase = System.Diagnostics.Debugger.IsAttached
|
dashboardOptions.PathBase = System.Diagnostics.Debugger.IsAttached
|
||||||
@ -100,8 +103,8 @@ namespace SJZY.Track.Application
|
|||||||
LogHelper.Error($@"
|
LogHelper.Error($@"
|
||||||
|-CAP失败回调事件:
|
|-CAP失败回调事件:
|
||||||
|-处理类型:{(faileCalback.MessageType == DotNetCore.CAP.Messages.MessageType.Subscribe ? "消费消息达到最大重试次数,需要开发人员介入" : "生产消息推送失败")}
|
|-处理类型:{(faileCalback.MessageType == DotNetCore.CAP.Messages.MessageType.Subscribe ? "消费消息达到最大重试次数,需要开发人员介入" : "生产消息推送失败")}
|
||||||
|-头部信息:{faileCalback.Message.Headers.ToJson()}
|
|-头部信息:{faileCalback?.Message?.Headers?.ToJson()}
|
||||||
|-消息内容:{((JsonElement?)faileCalback.Message.Value)?.GetRawText()}");
|
|-消息内容:{((JsonElement)faileCalback?.Message?.Value).GetRawText()}");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public partial class GlobalConst
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹推送后触发更新订单主表
|
/// 轨迹推送后触发更新订单主表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string TrackPushAfterUpdateOrderSubscribe = "SJZY.Traack.TrackPushAfterUpdateOrder";
|
public const string TrackPushAfterUpdateOrderSubscribe = "SJZY.Track.TrackPushAfterUpdateOrder";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关联订单后补轨迹
|
/// 关联订单后补轨迹
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user