大佬教程收集整理的这篇文章主要介绍了MassTransit - 无法覆盖 RoutingSlipResponseProxy,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试设置一个 RoutIngSlipResponseProxy
,如果没有 requestID
,它将阻止发送响应。我试图通过覆盖我的 Consume
中的 RoutIngSlipResponseProxy
方法来做到这一点,如下所示:@H_675_11@
public class MigrateResponseProxy : RoutIngSlipResponseProxy<IMigrationrequested,IMigrationComplete>
{
public new async Task Consume(ConsumeContext<RoutIngSlipCompleted> context)
{
var isrequest = context.@R_616_8798@ge.Variables.ContainsKey("requestID");
if (!isrequest)
return;
var request = context.@R_616_8798@ge.Getvariable<IMigrationrequested>("request");
var requestID = context.@R_616_8798@ge.Getvariable<GuID>("requestID");
Uri responseAddress = null;
if (context.@R_616_8798@ge.Variables.ContainsKey("ResponseAddress"))
responseAddress = context.@R_616_8798@ge.Getvariable<Uri>("ResponseAddress");
if (responseAddress == null)
throw new Argumentexception($"The response address Could not be found for the faulted routIng slip: {Context.@R_616_8798@ge.Trackingnumber}");
var endpoint = await context.GetResponseEndpoint<IMigrationComplete>(responseAddress,requestID).ConfigureAwait(false);
var response = await CreateResponse@R_616_8798@ge(context,request);
await endpoint.Send(responsE).ConfigureAwait(false);
}
... remaining code ...
}
这与 original method 的代码基本相同,只是在开头检查了 requestID。但是,在通过代码调试时,似乎从未调用过这个重写的方法,而是调用了父方法。有什么我可能在这里遗漏的吗?任何帮助将不胜感激。@H_675_11@
这些方法不是虚拟的,因此您将无法覆盖它们。在这种情况下,您最好将代理代码复制到您自己的项目中,而不是使用 MassTransit 中包含的实现。@H_675_11@
欢迎您提交 PR 以使这些方法虚拟化。@H_675_11@
以上是大佬教程为你收集整理的MassTransit - 无法覆盖 RoutingSlipResponseProxy全部内容,希望文章能够帮你解决MassTransit - 无法覆盖 RoutingSlipResponseProxy所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。