-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathOutboxMessage.cs
More file actions
67 lines (46 loc) · 1.58 KB
/
OutboxMessage.cs
File metadata and controls
67 lines (46 loc) · 1.58 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using FSH.Framework.Core.Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace FSH.Framework.Eventing.Outbox;
/// <summary>
/// Outbox message entity used to persist integration events alongside domain changes.
/// </summary>
[IgnoreAuditTrail]
public class OutboxMessage
{
public Guid Id { get; set; }
public DateTime CreatedOnUtc { get; set; }
public string Type { get; set; } = default!;
public string Payload { get; set; } = default!;
public string? TenantId { get; set; }
public string? CorrelationId { get; set; }
public DateTime? ProcessedOnUtc { get; set; }
public int RetryCount { get; set; }
public string? LastError { get; set; }
public bool IsDead { get; set; }
}
public class OutboxMessageConfiguration : IEntityTypeConfiguration<OutboxMessage>
{
private readonly string _schema;
public OutboxMessageConfiguration(string schema)
{
_schema = schema;
}
public void Configure(EntityTypeBuilder<OutboxMessage> builder)
{
ArgumentNullException.ThrowIfNull(builder);
builder.ToTable("OutboxMessages", _schema);
builder.HasKey(o => o.Id);
builder.Property(o => o.Type)
.HasMaxLength(512)
.IsRequired();
builder.Property(o => o.Payload)
.IsRequired();
builder.Property(o => o.TenantId)
.HasMaxLength(64);
builder.Property(o => o.CorrelationId)
.HasMaxLength(128);
builder.Property(o => o.CreatedOnUtc)
.IsRequired();
}
}