This commit is contained in:
李鹏军 2024-03-27 10:40:39 +08:00
parent cfb761a806
commit 6021e7c5d9
3 changed files with 9 additions and 9 deletions

View File

@ -3,7 +3,6 @@ using DotNetCore.CAP.Filter;
using SJZY.Expand.ABP.Core;
using SJZY.Expand.ABP.Core.Logger;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Domain.Consts;
namespace SJZY.Track.Application.EventHandlers;
@ -18,8 +17,6 @@ public class CAPFilter : SubscribeFilter
/// <returns></returns>
public override Task OnSubscribeExecutingAsync(ExecutingContext context)
{
if (context.DeliverMessage.Headers["cap-msg-name"] == GlobalConst.TrackRefreshSubscribe)
return Task.CompletedTask;
var argumentJsonStr = context.Arguments.ToJson();
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))
{
var isSkip = !string.IsNullOrEmpty(RedisHelper.Client.Get($"CapExcuteFilter:{hash}"));
if (isSkip)
throw new BusinessException(_ERROR_CODE, $"检测到重复消费,消费参数:{argumentJsonStr}");
// if (isSkip)
// throw new BusinessException(_ERROR_CODE, $"检测到重复消费,消费参数:{argumentJsonStr}");
RedisHelper.Client.Set($"CapExcuteFilter:{hash}", 60 * 10,
TimeSpan.FromHours(1).Seconds); // 1h内不允许一模一样的参数重复消费

View File

@ -85,8 +85,11 @@ namespace SJZY.Track.Application
configure.Password = configuration["RabbitMQ:Password"]!;
configure.Port = configuration.GetValue<int>("RabbitMQ:Port");
});
options.TopicNamePrefix = "v1";
options.SucceedMessageExpiredAfter = 6 * 60 * 60;
options.FailedRetryInterval = 60;
options.FailedRetryCount = 10;
options.FailedRetryCount = 3;
options.UseDashboard(dashboardOptions =>
{
dashboardOptions.PathBase = System.Diagnostics.Debugger.IsAttached
@ -100,8 +103,8 @@ namespace SJZY.Track.Application
LogHelper.Error($@"
|-CAP失败回调事件:
|-处理类型:{(faileCalback.MessageType == DotNetCore.CAP.Messages.MessageType.Subscribe ? "消费消息达到最大重试次数,需要开发人员介入" : "生产消息推送失败")}
|-头部信息:{faileCalback.Message.Headers.ToJson()}
|-消息内容:{((JsonElement?)faileCalback.Message.Value)?.GetRawText()}");
|-头部信息:{faileCalback?.Message?.Headers?.ToJson()}
|-消息内容:{((JsonElement)faileCalback?.Message?.Value).GetRawText()}");
}
catch (Exception ex)
{

View File

@ -30,7 +30,7 @@ public partial class GlobalConst
/// <summary>
/// 轨迹推送后触发更新订单主表
/// </summary>
public const string TrackPushAfterUpdateOrderSubscribe = "SJZY.Traack.TrackPushAfterUpdateOrder";
public const string TrackPushAfterUpdateOrderSubscribe = "SJZY.Track.TrackPushAfterUpdateOrder";
/// <summary>
/// 关联订单后补轨迹