从 Azure 队列中删除消息时出现异常?

发布于 2024-09-18 12:20:30 字数 1607 浏览 7 评论 0原文

我正在尝试使用 Windows Azure,并且遇到了一些必须很简单的事情,但我就是看不到它。

我有一个使用 Azure 队列的小测试:

public void CanPublishSillyLittleMessageOnQueue()
{
    var queueClient = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudQueueClient();
    var testQueue = queueClient.GetQueueReference("testqueue1");

    testQueue.CreateIfNotExist();
    var message = new CloudQueueMessage("This is a test");
    testQueue.AddMessage(message);

    CloudQueueMessage received;

    int sleepCount = 0;
    while((received = testQueue.GetMessage()) == null)
    {
        ++sleepCount;
        Thread.Sleep(25);
    }
    testQueue.DeleteMessage(received);

    Assert.Equal(message.AsString, received.AsString);
}

它发送消息很好 - 我可以在 SQL 表中看到它。然而,当它调用“testQueue.DeleteMessage(received)”方法时,我得到了这样的信息:

TestCase 'AzureExploratory.PlayingWithQueues.CanPublishSillyLittleMessageOnQueue'
failed: System.ArgumentNullException : Value cannot be null.
Parameter name: str
    at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
    at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
    at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImplWithRetry(Func`1 impl, RetryPolicy policy)
    at Microsoft.WindowsAzure.StorageClient.CloudQueue.DeleteMessage(CloudQueueMessage message)
    PlayingWithQueues.cs(75,0): at AzureExploratory.PlayingWithQueues.CanPublishSillyLittleMessageOnQueue()

这似乎是 Azure SDK 内部某个地方出现了故障。

我使用的是 VS 2010、.NET 4.0、Azure SDK V1.2、64 位 Win 7。开发人员商店服务正在运行;我可以看到消息进入队列,但我无法删除它们。

有人见过这样的事情吗?

I'm dipping my toes into Windows Azure, and I'm running into something that has to be simple, but I just can't see it.

I have this small test to play with Azure queues:

public void CanPublishSillyLittleMessageOnQueue()
{
    var queueClient = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudQueueClient();
    var testQueue = queueClient.GetQueueReference("testqueue1");

    testQueue.CreateIfNotExist();
    var message = new CloudQueueMessage("This is a test");
    testQueue.AddMessage(message);

    CloudQueueMessage received;

    int sleepCount = 0;
    while((received = testQueue.GetMessage()) == null)
    {
        ++sleepCount;
        Thread.Sleep(25);
    }
    testQueue.DeleteMessage(received);

    Assert.Equal(message.AsString, received.AsString);
}

It sends the message just fine - I can see it in the SQL table. However, when it hits the "testQueue.DeleteMessage(received)" method, I get this:

TestCase 'AzureExploratory.PlayingWithQueues.CanPublishSillyLittleMessageOnQueue'
failed: System.ArgumentNullException : Value cannot be null.
Parameter name: str
    at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
    at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
    at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImplWithRetry(Func`1 impl, RetryPolicy policy)
    at Microsoft.WindowsAzure.StorageClient.CloudQueue.DeleteMessage(CloudQueueMessage message)
    PlayingWithQueues.cs(75,0): at AzureExploratory.PlayingWithQueues.CanPublishSillyLittleMessageOnQueue()

which appears to be a failure somewhere down inside the guts of the Azure SDK.

I'm using VS 2010, .NET 4.0, the Azure SDK V1.2, 64-bit Win 7. The developer store service is running; I can see the messages go into the queue, I just can't delete them.

Anyone ever seen anything like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神回复 2024-09-25 12:20:30

我知道发生了什么事。有问题的代码正在 xUnit 测试工具中运行。事实证明,xUnit 运行程序默认情况下没有设置带有配置文件路径的应用程序域。 System.UriBuilder 现在会访问配置文件,因此它会崩溃。

解决方法是向测试项目添加一个空的 app.config。现在可以了。

啊啊!

I figured out what's going on. The code in question was running in a xUnit test harness. Turns out that the xUnit runner doesn't set up an appdomain with a config file path by default. System.UriBuilder now hits the config file, so it blows up.

The workaround was to add an empty app.config to the test project. Now it works.

ARGH!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文