【发布时间】:2017-06-09 19:40:03
【问题描述】:
我正在创建一个示例 Azure 服务总线应用程序。我创建了一个命名空间、主题和订阅。我已经为该主题编写了测试消息,如果我转到门户中的订阅,我会看到每次使用编写器应用程序编写新消息时都会收到一条新消息。
但是当我去拉消息时,什么都没有检索到。在故障排除中,我将订阅名称更改为不正确的值并收到错误消息。我改回来了,当我查看 Azure 门户时,我没有得到任何输出,也没有删除任何消息。我被卡住了……这看起来很简单,但它不起作用。
string connectionString = "Endpoint=sb://redacted for obvious reasons";
SubscriptionClient Client = SubscriptionClient.CreateFromConnectionString(connectionString, "NewOrders", "AllOrders");
// Configure the callback options.
OnMessageOptions options = new OnMessageOptions();
options.AutoComplete = false;
options.AutoRenewTimeout = TimeSpan.FromMinutes(1);
Client.OnMessage((message) =>
{
try
{
Console.WriteLine("Body: " + message.GetBody<string>());
message.Complete();
Console.ReadLine();
}
catch (Exception)
{
// Indicates a problem, unlock message in subscription.
message.Abandon();
}
}, options);
【问题讨论】:
-
您的订阅 AllOrders 是如何配置的?你能在 GitHub 上分享你的代码复制吗?
-
您正在运行控制台应用程序吗?你阻止线程不终止应用程序吗?
标签: azure azureservicebus