我正在使用EventProcessorHost和一个IEventProcessor类(调用它:MyEventProcessor)从EventHub接收事件.我通过在两台服务器上运行我的EPH,并使用相同的ConsumerGroup连接到Hub,但使用唯一的hostName(使用机器名称)将其扩展到两台服务器.
问题是:在白天/黑夜的随机时间,应用程序记录:
Exception information:
Exception type: ReceiverDisconnectedException
Exception message: New receiver with higher epoch of '186' is created hence current receiver with epoch '186' is getting disconnected. If you are recreating the receiver, make sure a higher epoch is used.
at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)
at Microsoft.ServiceBus.Common.Parallel.TaskHelpers.EndAsyncResult(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Run Code Online (Sandbox Code Playgroud)
此异常与LeaseLostException同时发生,当它尝试检查点时,从MyEventProcessor的CloseAsync方法抛出.(由于ReceiverDisconnectedException,可能正在调用Close?)
我认为这是由于Event Hubs在扩展到多台机器时的自动租赁管理而发生的.但我想知道我是否需要做一些不同的事情以使其更干净地工作并避免这些例外?例如:有时代的东西?
在我的VB.NET应用程序中,该事件AppDomain.CurrentDomain.AssemblyResolve有一个订阅它的处理程序.将ResolveEventHandler其订阅到这个活动是从我的代码加入上游(就我所知,System.AppDomain有自己Private Method订阅的事件)......是有可能从此活动中删除所有处理程序,这样我可以添加自己的处理程序和确保它是唯一的一个?
基本上我正在尝试这样做:
RemoveHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf ClassX.MethodX
Run Code Online (Sandbox Code Playgroud)
但是我不知道这个例子中是什么ClassX或者什么MethodX,因为我还没有为这个事件添加处理程序,并且这个处理程序是由上游代码添加的.我正在使用此处描述的方法来检查是否有任何处理程序是订阅事件:https:
//stackoverflow.com/a/2953318/734914
编辑:我能够在调试时使用立即窗口确定订阅事件的方法.
? DirectCast(gettype(System.AppDomain).GetField("AssemblyResolve", BindingFlags.Instance or BindingFlags.NonPublic).GetValue(AppDomain.CurrentDomain) , ResolveEventHandler)
{System.ResolveEventHandler}
_methodBase: Nothing
_methodPtr: 157334028
_methodPtrAux: 1827519884
_target: {System.ResolveEventHandler}
**Method: {System.Reflection.Assembly ResolveAssembly**(System.Object, System.ResolveEventArgs)}
Target: Nothing
Run Code Online (Sandbox Code Playgroud)
现在我试图删除它,就像这样,因为它不是一个Public方法:
RemoveHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf GetType(Reflection.Assembly).GetMethod("ResolveAssembly")
Run Code Online (Sandbox Code Playgroud)
但是这会给编译器错误说:"AddressOf参数必须是方法的名称".所以我不确定如何在这里指定非Public方法