gpt4 book ai didi

azure - 由于数据总线配置问题,nservicebus worker 角色在 azure 重新启动中

转载 作者:行者123 更新时间:2023-12-03 05:09:57 25 4
gpt4 key购买 nike

我有两个辅助角色设置为 nservicebus 端点 (nservicebus 3.2.8),并且都使用 AzureDataBus 配置来处理大于为 azure 队列分配的大小的消息。我的雇主不允许在配置中放置凭据,因此使用 IProvideConfiguration 来配置存储凭据。

这似乎有效,但是 nservicebus 似乎仍在尝试使用本地开发存储连接初始化数据总线 channel ,这导致辅助角色重新启动多次。最终它启动并选择正确的配置。

关于如何配置数据总线 channel ,我是否做错了什么?

以下是辅助角色事件日志中的异常:

An unhandled exception occurred. Type: System.Exception Process ID: 2420
Process Name: WaWorkerHost
Thread ID: 6
AppDomain Unhandled Exception for role My.WorkerRole.Assembly_IN_1
Exception: Exception when starting endpoint, error has been logged. Reason: Unable to connect to the remote server
at NServiceBus.Hosting.GenericHost.Start()
at NServiceBus.Hosting.Azure.RoleEntryPoint.Run()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRoleInternal()
at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<StartRole>b__1()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Inner Exception: Unable to connect to the remote server
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
at Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.CreateIfNotExist(BlobRequestOptions options)
at NServiceBus.DataBus.Azure.BlobStorage.BlobStorageDataBus.Start()
at System.EventHandler.Invoke(Object sender, EventArgs e)
at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start(Action startupAction)
at NServiceBus.Hosting.GenericHost.Start()

Inner Exception: No connection could be made because the target machine actively refused it 127.0.0.1:10000
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

这会立即导致进程终止:

Application: WaWorkerHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Exception
Stack:
at NServiceBus.Hosting.GenericHost.Start()
at NServiceBus.Hosting.Azure.RoleEntryPoint.Run()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRoleInternal()
at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<StartRole>b__1()
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()

这是我的端点配置:

internal class EndpointConfig : IConfigureThisEndpoint, AsA_Worker, IWantCustomInitialization
{
#region IWantCustomInitialization Members

public void Init()
{
Configure.With()
.DefaultBuilder()
.AzureConfigurationSource()
.MessageForwardingInCaseOfFault()
.AzureMessageQueue()
.JsonSerializer()
.AzureDataBus()
.AzureSubcriptionStorage()
.UnicastBus()
.DisableTimeoutManager()
.DisableSecondLevelRetries()
.IsTransactional(true)
.IsolationLevel(System.Transactions.IsolationLevel.ReadCommitted)
.PurgeOnStartup(false);
}
}

数据总线配置覆盖:

 public class ConfigOverride : IProvideConfiguration<AzureDataBusConfig>
{

AzureDataBusConfig IProvideConfiguration<AzureDataBusConfig>.GetConfiguration()
{
return new AzureDataBusConfig()
{
ConnectionString = "my storage key";
};
}

}

最佳答案

听起来像是初始化逻辑中的计时问题,基本上,您在 nsb 应用配置覆盖之前调用 AzureDataBus(),然后回退到默认设置。您可以尝试将 IWantCustomInitialization 放在一个单独的类中(比它稍后运行一点)。

如果这没有帮助,请随时向我发送一个小副本,我会看一下!

PS:您可以省略 .With().DefaultBuilder(),因为它无论如何都是默认值!

亲切的问候,伊夫

关于azure - 由于数据总线配置问题,nservicebus worker 角色在 azure 重新启动中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14679403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com