Service Bus订阅创建

编程入门 行业动态 更新时间:2024-10-24 00:19:43
本文介绍了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 GitHubservice-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订阅创建

本文发布于:2023-10-27 18:55:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534250.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Service   Bus

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!