简体   繁体   English

Azure事件中心 - 同一事件中心中的多个事件类型

[英]Azure Event Hub - multiple event types in same Event Hub

I have set up Azure Event Hub . 我已经设置了Azure Event Hub There are 2 publishers : 2个发布者

  1. Publisher 1 (with Send Policy) 发布者1(带发送政策)

  2. Publisher 2 (with Send Policy) 发布者2(带发送政策)

Publisher 1 will send Event 1 and Publisher 2 will send Event 2. Both Event 1 & Event 2 are different format. 发布者1将发送事件1,发布者2将发送事件2.事件1和事件2都是不同的格式。

Question 1 : This would mean we have different messages in EH - what are the tradeoff with this approach? 问题1 :这意味着我们在EH中有不同的信息 - 这种方法的权衡是什么? Should I instead create 2 EH (one for Publisher 1 and another for Publisher 2)? 我应该创建2个EH(一个用于Publisher 1,另一个用于Publisher 2)? What is the best practice and design philosophy? 什么是最佳实践和设计理念?

If I go with above approach, I would have to set up a Consumer with Listen Policy to look for these events and parse/transform these events and de-serialize these. 如果我采用上述方法,我将不得不设置一个带有Listen策略的Consumer来查找这些事件并解析/转换这些事件并对这些事件进行反序列化。

Question 2 : Would I need 2 Consumers (Consumer 1 and Consumer 2) to read messages meant for them ? 问题2 :我是否需要2个消费者(消费者1和消费者2)阅读针对他们的消息? (Consumer 1 will read only Event 1 and Consumer 2 will read only Event 2)? (消费者1只读事件1而消费者2只读事件2)?

Scenario 1: One Event Hub for multiple event types 场景1:多事件类型的一个事件中心

In this scenario you have multiple options when it comes to sending and processing the messages: 在这种情况下,您在发送和处理消息时有多个选项:

  1. Just send messages to the Event Hub. 只需向活动中心发送消息即可。 Write a consuming process that reads the messages and based on the type handle them different. 编写一个消费过程来读取消息,并根据类型处理不同的消息。
  2. Just send messages to the Event Hub. 只需向活动中心发送消息即可。 Create different consumer groups, one for each message type. 创建不同的使用者组,每种消息类型一个。 Have 2 processes that both read their own consumer group and skip the messages that they are not qualified to handle. 有2个进程可以读取自己的使用者组并跳过他们没有资格处理的消息。 (Each consumer group essentially read the same data, but they can be at different positions in the data stream). (每个消费者组基本上读取相同的数据,但它们可以位于数据流中的不同位置)。 See Azure event hubs and multiple consumer groups 请参阅Azure事件中心和多个使用者组
  3. Send the messages to a designated partition. 将消息发送到指定的分区。 For example, have messages of type A send to partition 1 and messages of type B to partition 2. This can however affect the scalability of the event hub. 例如,将类型A的消息发送到分区1,将类型B的消息发送到分区2.但是这会影响事件中心的可伸缩性。 Create dedicated processes per (set of) partition(s). 为每个(一组)分区创建专用进程。 Each process will then only process messages of the same type. 然后,每个进程只处理相同类型的消息。 See https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-programming-guide#partition-key and https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-programming-guide#create-a-partition-sender 请参阅https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-programming-guide#partition-keyhttps://docs.microsoft.com/en-us/azure/event -hubs /事件集线器编程导#创建-一个分区发送方

Scenario 2: An Event Hub per event types 场景2:每个事件类型的事件中心

This one is easy, just create 2 event hubs and 2 consuming processes. 这个很简单,只需创建2个事件中心和2个消耗过程。 But you'll have to manage 2 event hubs and given the abilities of an Event Hub it might be overkill. 但是你必须管理2个事件中心,并且考虑到事件中心的能力,它可能有点过分。

My advice 我的建议

It depends on the amount of data, but based on my experience I would go to send all messages the one event hub and have one process reading the message and perform an action based on the message type using some c# code. 这取决于数据量,但根据我的经验,我会将所有消息发送到一个事件中心,并让一个进程读取消息并使用一些c#代码基于消息类型执行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM