我准备开发连接到Azure Service Bus的应用程序。为了发展,我想使用Service Bus 1.1。Service Bus 1.1使用WindowsAzure.ServiceBus创建队列dll
我已经安装了localy Service Bus 1.1,并且它正常工作,当我连接到包Service Bus.v1_1 ver。 1.0.5。
但是,因为我想最终与Azure合作,我更愿意使用软件包WindowsAzure服务总线,因为我知道sholud使用Service Bus 1.1。
但是,当我要执行:
namespaceManager.QueueExists(queueName)
与WindowsAzure.ServiceBus版本3.1.2包我收到:
'System.ArgumentException' .... The remote server returned an error: (400) Bad Request. The api-version in the query string is not supported. Either remove it from the Uri or use one of '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();