NServiceBus 事件信息
我正在尝试确定我的事件 DTO 在发布/订阅场景中应包含哪些信息。
我看到两种可能性:
1)订阅者可能需要的所有信息
interface UserInvitedToGroup
{
string GroupName {get; set;}
string UserName {get; set;}
DateTime DateInvited {get; set;}
// etc, etc ...
}
或
2)仅受影响实体的 ID。
interface UserInvitedToGroup
{
int GroupId {get; set;}
int UserId {get; set;}
}
显然,在这种情况下,订阅者还需要访问数据存储才能获取实际可用的信息。
我倾向于第二种,因为我不确定订阅者到底需要什么信息。
I'm trying to decide what information my Event DTOs should contain in a pub/sub scenario.
I see two possibilities:
1) All the information that could be needed by subscribers
interface UserInvitedToGroup
{
string GroupName {get; set;}
string UserName {get; set;}
DateTime DateInvited {get; set;}
// etc, etc ...
}
or
2) Just the Id's of the entities affected.
interface UserInvitedToGroup
{
int GroupId {get; set;}
int UserId {get; set;}
}
Obviously in this scenario the subscriber would need access to the data store as well to get the information that is actually usable.
I lean towards the second since I am not sure exactly the information a subscriber will need.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会推荐#2。然后,如果订阅者对用户或组详细信息感兴趣,他们也可以订阅您的 UserCreated 和 GroupCreated 事件。
I would recommend #2. Then have you subscribers subscribe to your UserCreated and GroupCreated events as well if they are interested in the user or group details.