系统相关
首页 > 系统相关> > c# – Service Bus 1.1使用WindowsAzure.ServiceBus dll创建队列

c# – Service Bus 1.1使用WindowsAzure.ServiceBus dll创建队列

作者:互联网

我正准备开发连接到Azure Service Bus的应用程序.对于开发,我想使用Service Bus 1.1.

我已经安装了localy Service Bus 1.1,当我连接Service Service.v1_1 ver时,它工作正常. 1.0.5.

但是,由于我最终希望与Azure一起工作,我更喜欢使用WindowsAzure Service Bus,因为我知道sholud与Service Bus 1.1一起使用.

但是当我想要执行时:

namespaceManager.QueueExists(queueName)

使用WindowsAzure.ServiceBus ver 3.1.2包我收到:

‘System.ArgumentException’….
远程服务器返回错误:(400)错误请求.不支持查询字符串中的api-version.要么从Uri中删除它,要么使用’2012-03,2012-08,2013-04,2013-07’之一.

将?api_version = 2013-07添加到Uri没有帮助.

但是,向本地SB1.1上存在的队列发送消息的效果很好(使用WindowsAzure.ServiceBys 3.1.2).
所以它只适用于与NamespaceManager的连接.

任何人都有任何想法为什么它不起作用?

我用于测试的代码:

var cs ="Endpoint=sb://mylocalmachine/ServiceBusDefaultNamespace/;StsEndpoint=https://mylocalmachine:9355/ServiceBusDefaultNamespace/;RuntimePort=9354;ManagementPort=9355";
var queueName = "AAA";
var namespaceManager = NamespaceManager.CreateFromConnectionString(cs);
var messagingFactory = MessagingFactory.CreateFromConnectionString(cs);
var ver = namespaceManager.GetVersionInfo();

if (namespaceManager.QueueExists(queueName))
{
    namespaceManager.DeleteQueue(queueName);
}

namespaceManager.CreateQueue(queueName);

QueueClient client = messagingFactory.CreateQueueClient(queueName);
client.Send(new BrokeredMessage("Hello! " + DateTime.Now));


client = messagingFactory.CreateQueueClient(queueName, ReceiveMode.ReceiveAndDelete);
BrokeredMessage message = client.Receive();
if (message != null)
{
    Console.WriteLine(message.GetBody<string>());
}
Console.ReadKey();

解决方法:

据我所知,WindowsAzure.ServiceBus包与内部Windows Service Bus不兼容.我们坚持使用旧包装.

我相信这些库在大多数情况下都是源兼容的,所以当你迁移到使用Azure服务总线而不是本地时,它应该像交换包和更改身份验证机制和连接字符串以及重新编译和测试一样简单.

标签:c,azure,azureservicebus,servicebus
来源: https://codeday.me/bug/20190706/1397062.html