- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个控制台应用程序来读取 Azure 服务总线上的订阅中存在的所有代理消息。我那里有大约 3500 条消息。这是我读取消息的代码:
SubscriptionClient client = messagingFactory.CreateSubscriptionClient(topic, subscription);
long count = namespaceManager.GetSubscription(topic, subscription).MessageCountDetails.ActiveMessageCount;
Console.WriteLine("Total messages to process : {0}", count.ToString()); //Here the number is showing correctly
IEnumerable<BrokeredMessage> dlIE = null;
dlIE = client.ReceiveBatch(Convert.ToInt32(count));
当我执行代码时,在 dlIE 中,我只能看到 256 条消息。我也尝试过提供像 client.PrefetchCount
这样的预取计数,但它也只返回 256 条消息。
我认为一次可以检索的消息数量有一些限制。但是,在 RecieveBatch
方法的 msdn 页面上没有提到这样的事情。我该怎么做才能一次检索所有消息?
注意:
我只想读取消息,然后让它存在于服务总线上。因此我不使用 message.complete
方法。
我无法从服务总线中删除并重新创建主题/订阅。
编辑:
我使用 PeekBatch 而不是 ReceiveBatch,如下所示:
IEnumerable<BrokeredMessage> dlIE = null;
List<BrokeredMessage> bmList = new List<BrokeredMessage>();
long i = 0;
dlIE = subsciptionClient.PeekBatch(Convert.ToInt32(count)); // count is the total number of messages in the subscription.
bmList.AddRange(dlIE);
i = dlIE.Count();
if(i < count)
{
while(i < count)
{
IEnumerable<BrokeredMessage> dlTemp = null;
dlTemp = subsciptionClient.PeekBatch(i, Convert.ToInt32(count));
bmList.AddRange(dlTemp);
i = i + dlTemp.Count();
}
}
我的订阅中有 3255 条消息。第一次调用 peekBatch 时,它会收到 250 条消息。因此它进入带有 PeekBatch(250,3225)
的 while 循环。每次只收到250条消息。我在输出列表中的最终消息总数为 3500,其中有重复项。我无法理解这是怎么发生的。
最佳答案
我已经弄清楚了。订阅客户端会记住它检索到的最后一批,并在再次调用时检索下一批。
所以代码是:
IEnumerable<BrokeredMessage> dlIE = null;
List<BrokeredMessage> bmList = new List<BrokeredMessage>();
long i = 0;
while (i < count)
{
dlIE = subsciptionClient.PeekBatch(Convert.ToInt32(count));
bmList.AddRange(dlIE);
i = i + dlIE.Count();
}
感谢MikeWo的指导
注意:一次可以查看的消息数量似乎存在某种大小限制。我尝试使用不同的订阅,并且每个订阅获取的消息数量不同。
关于c# - SubscriptionClient.RecieveBatch 未检索所有代理消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33209406/
subscriptionClient.AbandonAsync 与 subscriptionClient.closeAsync 之间有什么区别。 我需要检查订阅客户端中是否存在主题。由于某些限制,我无
在 Azure 服务总线命名空间中,有一个 SubscriptionClient 类型,具有以这种方式启动 MessageSession 的方法:- MessageSession session =
在 Azure 服务总线命名空间中,有一个 SubscriptionClient 类型,具有以这种方式启动 MessageSession 的方法:- MessageSession session =
我正在使用 Azure 服务总线云服务和 Microsoft.Azure.ServiceBus 3.2.0 NuGet 包。我正在研究这个主题。 当我广告 SubscriptionClient 规则来
我正在尝试使用 Azure SubscriptionClient.PeekBatch(int count) 来查看消息。对于 0 - 9 的计数值,一切正常,但一旦我输入 > 9 的值,我只会收到 9
我有一个控制台应用程序来读取 Azure 服务总线上的订阅中存在的所有代理消息。我那里有大约 3500 条消息。这是我读取消息的代码: SubscriptionClient client = mess
如何停止从设置为事件驱动消息泵的订阅客户端接收消息?我目前有一些代码可以工作,但是当我连续运行两个测试时,它们会第二次中断。我相当确定消息仍在从我创建的第一个实例中的订阅中提取。 http://msd
我正在努力解决消息在死信队列中过快结束的问题。我已经指定了这样的 ExponentialRetry 策略: private readonly RetryExponential _ret
当订阅需要 session 时,Azure 服务总线订阅客户端是否支持使用 OnMessage 操作? 我有一个订阅,名为“TestSubscription”。它需要一个 sessionId 并包含通
如果我向某个主题发送一批消息,并使用订阅客户端读取消息,那么我似乎会按顺序接收消息,即每发送一条消息都会触发 OnMessageAsync,但是有一个每个接收事件之间有明显的(150+ 毫秒)延迟 发
如果我向某个主题发送一批消息,并使用订阅客户端读取消息,那么我似乎会按顺序接收消息,即每发送一条消息都会触发 OnMessageAsync,但是有一个每个接收事件之间有明显的(150+ 毫秒)延迟 发
我一直在研究 Azure 服务总线 2.0 版提供的新消息泵。特别是,我使用主题和订阅(而不是队列)。 我可以让消息泵与非 session 订阅一起工作,并且只要有brokeredMessage可用,
我在 SubscriptionClient 上调用 BeginReceive(),如下所示: client.BeginReceive(new TimeSpan(6, 0, 0), new AsyncC
我正在 .net Core 2.1 中编写一个控制台应用程序,我的目的是监听 ServiceBus 中某个主题的消息,并使用 NEST api 处理到达 Elasticsearch 的新消息(NEST
我正在尝试实现重试政策,但它一直被忽略。SubscriptionClient 中是否有属性覆盖我在创建客户端时提供的属性? 这是我试过的代码: _retryPolicy = new Microsoft
这很奇怪,我不确定,但我记得不久前我做了这样的事情 SubscriptionClient Client = SubscriptionClient.CreateFromConnectionString(
这很奇怪,我不确定,但我记得不久前我做了这样的事情 SubscriptionClient Client = SubscriptionClient.CreateFromConnectionString(
根据 Hasura 中的用户角色动态更改 Apollo SubscriptionClient 中的 header 的正确方法是什么? 堆: 下一篇JS 阿波罗 Auth0 Hasura(使用角色列存储
我是一名优秀的程序员,十分优秀!