Service Bus订阅创建 [英] Service Bus subscription creation

查看:295
本文介绍了Service Bus订阅创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建服务总线订阅失败"NAME"错误代码:InternalServerError和消息:CorrelationId:49f92880-ed43-49e1-88c5-c839b8536f84。



两天以来我遇到了这个错误。发生了什么?



代码:

 if(等待manager.TopicExistsAsync (sb.TopicPath))
{
if(!await manager.SubscriptionExistsAsync(sb.TopicPath,sb.Name)){
await manager.CreateSubscriptionAsync(sb);
}
}

谢谢

解决方案

您可以尝试以下样本,看看它是否有帮助。完整的样本在GitHub上, service-bus-dotnet-management


 private static async Task CreateSubscription()
{
try
{
if(string.IsNullOrEmpty(namespaceName))
{
throw new Exception(" Namespace name is empty!") ;
}

var token = await GetToken();

var creds = new TokenCredentials(token);
var sbClient = new ServiceBusManagementClient(creds)
{
SubscriptionId = appOptions.SubscriptionId,
};

var subscriptionParams = new SBSubscription
{
MaxDeliveryCount = 10
};

Console.WriteLine(" Creating subscription ...");
await sbClient.Subscriptions.CreateOrUpdateAsync(resourceGroupName,namespaceName,TopicName,SubscriptionName,subscriptionParams);
Console.WriteLine("创建订阅成功。");
}
catch(例外e)
{
Console.WriteLine("无法创建订阅...");
Console.WriteLine(e.Message);
throw e;
}
}



Failed creating Service Bus subscription "NAME" with error code: InternalServerError and with message: CorrelationId: 49f92880-ed43-49e1-88c5-c839b8536f84.

Since two days I'm got this error. What's going on?

CODE:

 if (await manager.TopicExistsAsync(sb.TopicPath))
{
   if (!await manager.SubscriptionExistsAsync(sb.TopicPath, sb.Name))                        {
                            await manager.CreateSubscriptionAsync(sb);
                        }
}

Thanks

解决方案

Can you try below samples and see if it helps. The complete samples is there on the GitHub service-bus-dotnet-management.

private static async Task CreateSubscription()
		{
			try
			{
				if (string.IsNullOrEmpty(namespaceName))
				{
					throw new Exception("Namespace name is empty!");
				}

				var token = await GetToken();

				var creds = new TokenCredentials(token);
				var sbClient = new ServiceBusManagementClient(creds)
				{
					SubscriptionId = appOptions.SubscriptionId,
				};

				var subscriptionParams = new SBSubscription
				{
                    MaxDeliveryCount = 10
				};

				Console.WriteLine("Creating subscription...");
				await sbClient.Subscriptions.CreateOrUpdateAsync(resourceGroupName, namespaceName, TopicName, SubscriptionName, subscriptionParams);
				Console.WriteLine("Created subscription successfully.");
			}
			catch (Exception e)
			{
				Console.WriteLine("Could not create a subscription...");
				Console.WriteLine(e.Message);
				throw e;
			}
		}


这篇关于Service Bus订阅创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆