Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

ManagementClient CreateQueueAsync and CreateTopicAsync throw FormatException instead of MessagingEntityAlreadyExistsException #516

Closed
SeanFeldman opened this issue Jun 26, 2018 · 9 comments
Labels

Comments

@SeanFeldman
Copy link
Collaborator

SeanFeldman commented Jun 26, 2018

Repro:

var client1 = new ManagementClient(connectionString);
	
var task1 = client1.CreateTopicAsync("topic");
var task2 = client1.CreateTopicAsync("topic");
	
await Task.WhenAll(task1, task2);

Expected exception: MessagingEntityAlreadyExistsException
Actual exception: FormatException, "Cannot add value because header 'Authorization' does not support multiple values."

Stacktrace at System.Net.Http.Headers.HttpHeaders.ParseAndAddValue(String name, HeaderStoreItemInfo info, String value) at Microsoft.Azure.ServiceBus.Management.ManagementClient.d__42.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 Microsoft.Azure.ServiceBus.Management.ManagementClient.<>c__DisplayClass37_0.<b__0>d.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 Microsoft.Azure.ServiceBus.RetryPolicy.d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Azure.ServiceBus.RetryPolicy.d__18.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.TaskAwaiter.ValidateEnd(Task task) at Microsoft.Azure.ServiceBus.Management.ManagementClient.d__37.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 Microsoft.Azure.ServiceBus.Management.ManagementClient.d__29.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.TaskAwaiter`1.GetResult() at UserQuery.d__0.MoveNext()
@SeanFeldman SeanFeldman changed the title ManagementClient.CreateTopicAsync throws FormatException insteade of MessagingEntityAlreadyExistsException ManagementClient.CreateTopicAsync throws FormatException instead of MessagingEntityAlreadyExistsException Jun 26, 2018
@SeanFeldman SeanFeldman changed the title ManagementClient.CreateTopicAsync throws FormatException instead of MessagingEntityAlreadyExistsException ManagementClient.CreateXXXXAsync throws FormatException instead of MessagingEntityAlreadyExistsException Jun 26, 2018
@SeanFeldman SeanFeldman changed the title ManagementClient.CreateXXXXAsync throws FormatException instead of MessagingEntityAlreadyExistsException ManagementClient CreateTopicAsync and CreateQueueAsync throw FormatException instead of MessagingEntityAlreadyExistsException Jun 26, 2018
@SeanFeldman SeanFeldman changed the title ManagementClient CreateTopicAsync and CreateQueueAsync throw FormatException instead of MessagingEntityAlreadyExistsException ManagementClient.CreateQueueAsync throws FormatException instead of MessagingEntityAlreadyExistsException Jun 26, 2018
@SeanFeldman SeanFeldman changed the title ManagementClient.CreateQueueAsync throws FormatException instead of MessagingEntityAlreadyExistsException ManagementClient CreateQueueAsync and CreateTopicAsync throw FormatException instead of MessagingEntityAlreadyExistsException Jun 26, 2018
@nemakam
Copy link
Contributor

nemakam commented Jun 26, 2018

The issue was due to RetryPolicy. Your method must have run into some issue and retryPolicy kicked in which is trying to re send the same message. Fixed it in the latest commit.

  1. Changed default retry policy to None.
  2. If retry policy even kicks in, then make sure I clone the request before I try to send it again.

@nemakam nemakam closed this as completed Jun 26, 2018
@nemakam
Copy link
Contributor

nemakam commented Jun 26, 2018

Its fixed in #481

@SeanFeldman
Copy link
Collaborator Author

Should the default retry policy be set to None if request is cloned? Sounds like that was the root problem.

@nemakam
Copy link
Contributor

nemakam commented Jun 27, 2018

I was planning to remove retry policy completely instead.
Lets say you do "CreateTopic", and there was a Timeout exception. The default policy would try to retry creating it, and ends up throwing MessagingEntityAlreadyExistsException which is weird since you know the topic didnt exist.
So I changed the default to NoRetry

@SeanFeldman
Copy link
Collaborator Author

Then 👍 to remove it.

@nemakam
Copy link
Contributor

nemakam commented Jun 27, 2018

I'm going to leave default as NoRetry and let it be as is.
If someone is just interested in doing say GetTopic or something like that, and he knows what he is doing, there will be an option for him

@SeanFeldman
Copy link
Collaborator Author

SeanFeldman commented Jun 27, 2018 via email

@nemakam
Copy link
Contributor

nemakam commented Jun 27, 2018

Done.. Removed RetryPolicy

@SeanFeldman
Copy link
Collaborator Author

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants