(三)MMA(KeyCloak身份服务器/OutBox Pattern)
文章目录
- 项目地址
- 一、KeyCloak
- 二、OutBox Pattern
- 2.1 配置Common模块的OutBox
- 1. OutboxMessage
- 2. 数据库配置OutboxMessageConfiguration
- 3. 创建Save前的EF拦截器
- 4. 创建Quartz后台任务
- 5. 配置后台任务
- 6. 注册服务
- 2.2 创建OutBox的消费者
项目地址
- 教程作者:
- 教程地址:
- 代码仓库地址:
- 所用到的框架和插件:
dbt
airflow
一、KeyCloak
王教员 029-033
二、OutBox Pattern
王 38-40
2.1 配置Common模块的OutBox
1. OutboxMessage
- 定义Outbox message
namespace Evently.Common.Infrastructure.Outbox;public sealed class OutboxMessage
{//消息idpublic Guid Id { get; init; }//消息类型 例如UserRegisteredEventpublic string Type { get; init; }//消息内容 Json格式public string Content { get; init; }//消息发生时间public DateTime OccurredOnUtc { get; init; }//消息处理时间,可为空,表示没有被消费public DateTime? ProcessedOnUtc { get; init; }//消息错误信息public string? Error { get; init; }
}
2. 数据库配置OutboxMessageConfiguration
- 创建OutBoxMessage表需要用到的数据库配置
namespace Evently.Common.Infrastructure.Outbox;
public sealed class OutboxMessageConfiguration : IEntityTypeConfiguration<OutboxMessage>
{public void Configure(EntityTypeBuilder<OutboxMessage