[英]Cant connect to azure service bus topic using java
我正在尝试使用Java代码连接到Azure服务总线主题。 我已经在azure门户中创建了一个主题。
我正在尝试使用具有参数名称空间,authenticationName,authenticationPassword,serviceBusRootUri, wrapRootUri的方法configureWithWrapAuthentication进行配置。
我获得了除wrapRootUri之外的所有参数值。 仅供参考:我已选择该地区为印度南部
我需要知道wrapRootUri对于南印度位置的价值是什么。
请帮忙! 提前致谢。
服务总线团队正在从ACS转换为SAS。 看来它不再起作用。 根据github的说法,这是一个未解决的问题 。
如果要连接或管理Azure服务总线。 我建议您可以使用以下SDK 。
<!-- 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>
更新 :添加软件包信息。
演示代码
import com.microsoft.azure.servicebus.ClientSettings;
import com.microsoft.azure.servicebus.Message;
import com.microsoft.azure.servicebus.TopicClient;
import com.microsoft.azure.servicebus.management.ManagementClient;
import com.microsoft.azure.servicebus.management.TopicDescription;
import com.microsoft.azure.servicebus.primitives.ConnectionStringBuilder;
import com.microsoft.azure.servicebus.security.SharedAccessSignatureTokenProvider;
import com.microsoft.azure.servicebus.security.TokenProvider;
String connectionString = "Endpoint=sb://yoursevicebusNamespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xxxxx";
ConnectionStringBuilder connectionStringBuilder = new ConnectionStringBuilder(connectionString);
ManagementClient client = new ManagementClient(connectionStringBuilder);
//create topic
if(!client.queueExists("topicName"))
{
TopicDescription topic = client.createTopic("topicName");
}
TokenProvider tokenProvider = new SharedAccessSignatureTokenProvider("RootManageSharedAccessKey","xxxxxx",30);
ClientSettings clientSettings = new ClientSettings(tokenProvider){};
//create topicClient
TopicClient topicClient = new TopicClient(connectionStringBuilder.getEndpoint(),"topicName",clientSettings);
//send message
topicClient.send(new Message("test message"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.