A couple of problems when running the Azure Brokered Messaging Sample
-
24 iulie 2012 07:51
I'm trying out the Azure Service Bus Brokered Messaging tutorial (http://msdn.microsoft.com/en-us/library/windowsazure/hh367512.aspx). I've created the following function as required by the tutorial.
I get the following error on this line when creating the queue
myQueue = namespaceClient.CreateQueue("MyNewQueue");
The remote server returned an error: (400) Bad Request. 'https://omarramantutorials.servicebus.windows.net/MyNewQueue/?api-version=2012-03' contain character(s) that is not allowed by Service Bus. Entity segments can contain only letters, numbers, periods (.), hyphens (-), and underscores (_)..TrackingId:7dbe8f42-e382-4c1a-971b-b7d2bbf04314_2,TimeStamp:7/24/2012 7:38:36 AM
where omarramantutorials is the service bus namespace.
If I comment out these lines,
//QueueDescription myQueue;
//myQueue = namespaceClient.CreateQueue("MyNewQueue");and create the queue through the Azure Portal in the Service Bus and then run the sample, I then get
The server was unable to process the request due to an internal error..TrackingId:0f4f085a-f5b0-4afc-a1d6-d2eb3daf6512_1_0,TimeStamp:7/24/2012 7:43:17 AM
on the line
myQueueClient.Send(issue);
I wondered if anyone could help with either of these questions.
Thanks in advance.
Omar
static void Queue() { ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http; // Create management credentials TokenProvider credentials = TokenProvider.CreateSharedSecretTokenProvider(IssuerName, IssuerKey); // Create namespace client NamespaceManager namespaceClient = new NamespaceManager(ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty), credentials); QueueDescription myQueue; myQueue = namespaceClient.CreateQueue("MyNewQueue"); MessagingFactory factory = MessagingFactory.Create(ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty), credentials); QueueClient myQueueClient = factory.CreateQueueClient("MyNewQueue"); // Send messages Console.WriteLine("Now sending messages to the Queue."); for (int count = 0; count < 6; count++) { var issue = MessageList[count]; issue.Label = issue.Properties["IssueTitle"].ToString(); myQueueClient.Send(issue); Console.WriteLine(string.Format("Message sent: {0}, {1}", issue.Label, issue.MessageId)); } Console.WriteLine("Now receiving messages from Queue."); BrokeredMessage message; while ((message = myQueueClient.Receive(new TimeSpan(hours: 0, minutes: 0, seconds: 5))) != null) { Console.WriteLine(string.Format("Message received: {0}, {1}, {2}", message.SequenceNumber, message.Label, message.MessageId)); message.Complete(); Console.WriteLine("Processing message (sleeping...)"); Thread.Sleep(1000); } factory.Close(); myQueueClient.Close(); namespaceClient.DeleteQueue("MyNewQueue"); }
Toate mesajele
-
24 iulie 2012 13:20Moderator
I ran your code and it created the queue and sent messages to it just fine. So I can only think that there may be an issue with the values you have set in your IssuerName, IssuerKey, or ServiceNamespace values.
That said, I would offer some caution on the code as its not exactly the most resilient solution. You're not checking to see if the queue exists or handling any exceptions (MessagingEntityAlreadyExistsException) that could arise.
Your code should work fine for an isolated demonstration, but you'll want to add some of these if you plan to run this in a cloud app.
- Marcat ca răspuns de Arwind - MSFTModerator 30 iulie 2012 09:05
-
6 august 2012 07:38Thanks for looking it, that helped.