gpt4 book ai didi

java - 如何使用 Java 在 Azure 服务总线中创建队列?

转载 作者:行者123 更新时间:2023-11-29 04:15:38 25 4
gpt4 key购买 nike

我需要从代码中配置服务总线队列,但我似乎找不到有关如何执行此操作的任何详细信息。 Azure 服务总线库有一个正在创建队列 ( link ) 的单元测试,但我引用的 Maven 库没有任何这些类(QueueDescription 或 ManagementClientAsync)。

有人尝试过从java动态创建队列吗?

Maven:

<dependency> 
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-servicebus</artifactId>
<version>1.2.5</version>
</dependency>

最佳答案

I've referenced doesn't have any of those classes (QueueDescription or ManagementClientAsync).

However this class seem not to be part of azure-core or azure-servicebus librairy and I can seem to find which lib to add to the project to have access to those class.

您提到的QueueDescriptionManagementClientAsync似乎仅在2.0.0-PREVIEW version中可用。请尝试使用以下依赖项。

<!-- https://mvnrepository.com/artifact/com.microsoft.azure/azure-servicebus -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-servicebus</artifactId>
<version>2.0.0-PREVIEW-5</version>
</dependency>

演示代码:

String connectionString = "Endpoint=sb://xxxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xxxxxx";
ConnectionStringBuilder connectionStringBuilder = new ConnectionStringBuilder(connectionString);
ManagementClient client = new ManagementClient(connectionStringBuilder);
if(!client.queueExists("queueName"))
{
QueueDescription queue = client.createQueue("queueName");
}

关于java - 如何使用 Java 在 Azure 服务总线中创建队列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52540897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com