0

nservicebus エンドポイント (nservicebus 3.2.8) として 2 つのワーカー ロールをセットアップしており、どちらも Azure キューに割り当てられたサイズよりも大きいメッセージに対して AzureDataBus 構成を使用しています。私の雇用主は資格情報を構成に配置することを許可していないため、IProvideConfiguration を使用してストレージ資格情報を構成します。

これは機能しているように見えますが、nservicebus がまだローカルの開発ストレージ接続を使用してデータバス チャネルを初期化しようとしているようで、これによりワーカー ロールが数回再起動されます。最終的には起動し、正しい構成を取得します。

データバス チャネルの設定方法に関して、何か間違ったことをしていますか?

worker ロールのイベント ログからの例外を次に示します。

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";
            };
        } 

    }
4

1 に答える 1

3

初期化ロジックのタイミングの問題のように聞こえます。基本的には、構成のオーバーライドが nsb によって適用される前に AzureDataBus() を呼び出し、デフォルト設定にフォールバックします。IWantCustomInitialization を別のクラスに入れてみてください (少し後で実行されます)。

これで問題が解決しない場合は、お気軽に小さな再現ファイルを送ってください。確認します。

PS: .With().DefaultBuilder() は省略できます。これがデフォルトであるためです。

よろしく、イヴ

于 2013-02-04T20:30:04.540 に答える