作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在寻找一个很好的解决方案来记录失败的消息,在超过重试限制后,无需处理错误队列。到目前为止我发现了什么:
最佳答案
我已经结束了这个解决方案:
class MessageInterceptor: IInboundMessageInterceptor
{
public void PreDispatch(IConsumeContext context)
{
MessageTracker.Register(context);
}
public void PostDispatch(IConsumeContext context)
{}
}
class MessageTracker: InMemoryInboundMessageTracker
{
readonly Logger logger;
static readonly ConcurrentDictionary<string, IConsumeContext> DispatchingCache = new ConcurrentDictionary<string, IConsumeContext>();
public MessageTracker(int retryLimit, Logger logger)
: base(retryLimit)
{
this.logger = logger;
}
public static void Register(IConsumeContext context)
{
DispatchingCache.GetOrAdd(context.MessageId, context);
}
public override void MessageWasReceivedSuccessfully(string id)
{
base.MessageWasReceivedSuccessfully(id);
IConsumeContext value;
DispatchingCache.TryRemove(id, out value);
}
public override bool IsRetryLimitExceeded(string id, out Exception retryException, out IEnumerable<Action> faultActions)
{
var result = base.IsRetryLimitExceeded(id, out retryException, out faultActions);
IConsumeContext failed;
if (!result || !DispatchingCache.TryRemove(id, out failed))
return result;
// --> log failed IConsumeContext with exception
return true;
}
}
serviceBus = ServiceBusFactory.New(config =>
{
...
config.AddBusConfigurator(new PostCreateBusBuilderConfigurator(sb =>
{
var interceptorConfig = new InboundMessageInterceptorConfigurator(sb.InboundPipeline);
interceptorConfig.Create(new MessageInterceptor());
}));
config.SetDefaultInboundMessageTrackerFactory(retryLimit => new MessageTracker(retryLimit, LogManager.GetCurrentClassLogger()));
});
关于.net - 如何在大众运输中记录失败的消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20118709/
我想知道是否有人可以在不卡住浏览器的情况下使用 jquery 进行最大程度的 dom 操作提供一些安全指南。 也是大规模 DOM 操作的最佳方法。 基本上在任何时候我都可以处理多达 40k li 的列
我是一名优秀的程序员,十分优秀!