SzymonPobiega / NServiceBus.Raw

Sending and receiving raw messages using NServiceBus transport infrastructure
MIT License
6 stars 6 forks source link

Misleading exception when using RoundRobinNameSpacePartitioning and a single namespace #3

Open jdrat2000 opened 7 years ago

jdrat2000 commented 7 years ago

I am working on using the transport adapter for Azure and ServiceControl. Since I am running in a single namespace I only add a single namespace to the routing topology. When doing so I mistakenly left the RoundRobinNamespacePartitioning strategy as in the example.

As indicated in the documentation this is an invalid choice for a single namespace scenario but the exception that is thrown is not the correct one. The intended message about the multiple namespace requirement is buried a bit deep.

System.Exception was unhandled
  HResult=-2146233088
  Message=Failed to build type: NServiceBus.Transport.AzureServiceBus.INamespacePartitioningStrategy
  Source=NServiceBus.Azure.Transports.WindowsAzureServiceBus
  StackTrace:
       at NServiceBus.Transport.AzureServiceBus.TransportPartsContainer.Resolve(Type typeToBuild) in C:\BuildAgent\work\2f57832e2eee436e\src\Transport\Utils\TransportPartsContainer.cs:line 92
       at NServiceBus.Transport.AzureServiceBus.ForwardingTopologySectionManager.DetermineResourcesToCreate(QueueBindings queueBindings) in C:\BuildAgent\work\2f57832e2eee436e\src\Transport\Topology\Topologies\ForwardingTopologySectionManager.cs:line 58
       at NServiceBus.Transport.AzureServiceBus.TransportResourcesCreator.<CreateQueueIfNecessary>d__4.MoveNext() in C:\BuildAgent\work\2f57832e2eee436e\src\Transport\Seam\TransportResourcesCreator.cs:line 31
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at NServiceBus.Raw.InitializableRawEndpoint.<Initialize>d__1.MoveNext() in C:\BuildAgent\work\1f80a90dcd7c141d\src\NServiceBus.Raw\InitializableRawEndpoint.cs:line 56
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at NServiceBus.Raw.RawEndpoint.<Start>d__1.MoveNext() in C:\BuildAgent\work\1f80a90dcd7c141d\src\NServiceBus.Raw\RawEndpoint.cs:line 27
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at ServiceControl.TransportAdapter.AuditForwarder`2.<Start>d__3.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at ServiceControl.TransportAdapter.ServiceControlTransportAdapter`2.<Start>d__1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
       at Program.<AsyncMain>d__1.MoveNext() in C:\Projects\GitHub\NServiceBus.DynamicsAdapter\SControlTransportAdapter\Program.cs:line 95
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
       at Program.Main() in C:\Projects\GitHub\NServiceBus.DynamicsAdapter\SControlTransportAdapter\Program.cs:line 12
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
       HResult=-2146232828
       Message=Exception has been thrown by the target of an invocation.
       Source=mscorlib
       StackTrace:
            at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
            at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
            at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
            at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
            at System.Activator.CreateInstance(Type type, Object[] args, Object[] activationAttributes)
            at NServiceBus.Transport.AzureServiceBus.TransportPartsContainer.<>c__DisplayClass12_0.<DetermineFunc>b__2() in C:\BuildAgent\work\2f57832e2eee436e\src\Transport\Utils\TransportPartsContainer.cs:line 135
            at NServiceBus.Transport.AzureServiceBus.TransportPartsContainer.Resolve(Type typeToBuild) in C:\BuildAgent\work\2f57832e2eee436e\src\Transport\Utils\TransportPartsContainer.cs:line 66
       InnerException: 
            BareMessage=The 'RoundRobinNamespacePartitioning' strategy requires more than one namespace for the purpose of partitioning, found 1. , please use NamespacePartitioning().AddNamespace() to register additional namespaces
            HResult=-2146232062
            Line=0
            Message=The 'RoundRobinNamespacePartitioning' strategy requires more than one namespace for the purpose of partitioning, found 1. , please use NamespacePartitioning().AddNamespace() to register additional namespaces
            Source=NServiceBus.Azure.Transports.WindowsAzureServiceBus
            StackTrace:
                 at NServiceBus.RoundRobinNamespacePartitioning..ctor(ReadOnlySettings settings) in C:\BuildAgent\work\2f57832e2eee436e\src\Transport\Addressing\Partitioning\Strategies\RoundRobinNamespacePartitioning.cs:line 27
            InnerException: 
SzymonPobiega commented 7 years ago

@jdrat2000 does it throw a better exception when using regular NServiceBus (not Raw)? I suspect this is a transport-related issue.

jdrat2000 commented 7 years ago

Not sure @SzymonPobiega . I haven't tested that but may be able to if can get the project working.