azure-service-bus-dotnet icon indicating copy to clipboard operation
azure-service-bus-dotnet copied to clipboard

Missing MessagingEntityAlreadyExistsException

Open SeanFeldman opened this issue 6 years ago • 2 comments

In lue of this exception type, one has to handle the general ServiceBusException and filter based on part of the exception message. Doing so is not ideal as it could lead failure in the future where exception message would be modified.

NuGet package version or commit ID: 3.0.2

SeanFeldman avatar Jun 14 '18 18:06 SeanFeldman

What's the scenario? When you are creating a new Queue? This isn't supported in any nuget package as of now. Are you referring to the changes in the PR?

nemakam avatar Jun 14 '18 21:06 nemakam

My bad, should have provided a scenario. This is not about a queue. In my scenario it was related to creating a Rule with SubscriptionClient and that rule name was already there.

Repro:

await client.AddRuleAsync(rule).ConfigureAwait(false); // assuming this rule didn't exist before
await client.AddRuleAsync(rule).ConfigureAwait(false); // throws

Forced workaround

try
{
  await client.AddRuleAsync(rule).ConfigureAwait(false);
}
catch (ServiceBusException exception) when (exception.Message.Contains("already exists")) // unreliable
{
}

SeanFeldman avatar Jun 14 '18 23:06 SeanFeldman