-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathInboxMessage.cs
More file actions
52 lines (38 loc) · 1.28 KB
/
InboxMessage.cs
File metadata and controls
52 lines (38 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using FSH.Framework.Core.Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace FSH.Framework.Eventing.Inbox;
/// <summary>
/// Inbox message to track processed integration events per handler for idempotent consumers.
/// </summary>
[IgnoreAuditTrail]
public class InboxMessage
{
public Guid Id { get; set; }
public string EventType { get; set; } = default!;
public string HandlerName { get; set; } = default!;
public DateTime ProcessedOnUtc { get; set; }
public string? TenantId { get; set; }
}
public class InboxMessageConfiguration : IEntityTypeConfiguration<InboxMessage>
{
private readonly string _schema;
public InboxMessageConfiguration(string schema)
{
_schema = schema;
}
public void Configure(EntityTypeBuilder<InboxMessage> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.ToTable("InboxMessages", _schema);
builder.HasKey(i => new { i.Id, i.HandlerName });
builder.Property(i => i.EventType)
.HasMaxLength(512)
.IsRequired();
builder.Property(i => i.HandlerName)
.HasMaxLength(256)
.IsRequired();
builder.Property(i => i.TenantId)
.HasMaxLength(64);
}
}