在实现这种架构时,您应该考虑应用 CQRS 的原则——查询(此用户/密码组合是否有效)不应通过总线完成;命令(更改密码、忘记密码)通过总线发送,而不是作为事件发布。虽然在内部您可能会使用事件来保持命令和查询端同步,但这不涉及客户端。
可以使用简单的 ado.net 对数据库的复制读取从属设备进行查询 - 这就是 CQRS 中的持久视图模型。如果你喜欢,你也可以在前面放一些简单的 WCF。
使用 MSMQ 时,所有消息都通过存储转发传递。这意味着它们在传递到服务器之前首先存储在客户端上,因此如果服务器关闭,消息会在客户端等待。对于容错,您将希望您的消息是可恢复的(写入磁盘) - 这是 NServiceBus 中的默认值,但不是标准 MSMQ 的默认值(不了解 MassTransit)。您不需要为此使用数据库。
In NServiceBus, the bus is not installed on a separate machine so you don't need to deal with its availability independently of the rest of the system. It's only when you look at scaling our your command processing to more nodes that you might consider using the message-based load balancer in NServiceBus (called the distributor) which, for high availability, should be installed on a cluster or fault-tolerant hardware.