阅读事件中心文档并创建简单的生产者-消费者示例
我想知道在生产应用程序中这是如何工作的。原因是在当前实现中监听特定时间后连接将关闭。
我们是否应该将请求发送到特定的 REST 端点并在生产者完成后激活监听器?
最佳答案
您是对的,在大多数生产场景中这不起作用。最好的办法是在应用程序的生命周期内保持监听器打开。在大多数情况下,当触发应用程序重新启动时,处理应从上一个检查点继续继续。该示例不涉及这一点。
来自docs :
For the majority of production scenarios, we recommend that you use the event processor client for reading and processing events. The processor client is intended to provide a robust experience for processing events across all partitions of an event hub in a performant and fault tolerant manner while providing a means to checkpoint its progress. Event processor clients can work cooperatively within the context of a consumer group for a given event hub. Clients will automatically manage distribution and balancing of work as instances become available or unavailable for the group.
Here是处理事件与检查点相结合的示例。出于演示目的,监听器会在一段时间后停止。只要进程不停止,您就必须修改代码才能运行。
如果您有连续发送的事件流,则检查点非常重要。如果监听器在一段时间内不可用,您确实希望不仅从第一个事件开始或仅从新事件开始恢复处理。相反,您需要从最后一次知道的已处理事件开始。
关于javascript - Azure 事件中心监听事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65158827/