问题
I am preparing to develop application that connects to Azure Service Bus. For development I want use Service Bus 1.1.
I have installed localy Service Bus 1.1 and it works fine when I am connecting with package Service Bus.v1_1 ver. 1.0.5.
But as I want eventually work with Azure I prefer to use package WindowsAzure Service Bus which as I know sholud work with Service Bus 1.1.
But when I want to execute:
namespaceManager.QueueExists(queueName)
with WindowsAzure.ServiceBus ver 3.1.2 package I receive:
'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'.
Adding ?api_version=2013-07
to Uri does not helps.
However sending message to queue that exists on local SB1.1 works well (Using WindowsAzure.ServiceBys 3.1.2). So it just applies to connections with NamespaceManager.
Could anyone has any ideas why it does not work ?
The code I use for tests:
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();
回答1:
To my knowledge the WindowsAzure.ServiceBus package is not compatible with on premises Windows Service Bus. We are stuck with using the old package.
I believe the libraries are source compatible for most things, so when you DO migrate to using Azure service bus instead of on-prem, then it should be as simple as swapping out the package and changing the authentication mechanisms and connection strings and recompiling and testing.
来源:https://stackoverflow.com/questions/34767609/service-bus-1-1-creating-queue-with-windowsazure-servicebus-dll