forked from JasperFx/wolverine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutgoingMessage.cs
More file actions
38 lines (32 loc) · 1.01 KB
/
OutgoingMessage.cs
File metadata and controls
38 lines (32 loc) · 1.01 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
using Wolverine.Runtime.Serialization;
namespace Wolverine.RavenDb.Internals;
public class OutgoingMessage
{
public OutgoingMessage()
{
}
public OutgoingMessage(Envelope envelope)
{
Id = envelope.Id.ToString();
OwnerId = envelope.OwnerId;
Attempts = envelope.Attempts;
Body = EnvelopeSerializer.Serialize(envelope);
MessageType = envelope.MessageType!;
Destination = envelope.Destination;
DeliverBy = envelope.DeliverBy?.ToUniversalTime();
}
public string Id { get; set; }
public int OwnerId { get; set; }
public Uri? Destination { get; set; }
public DateTimeOffset? DeliverBy { get; set; }
public byte[] Body { get; set; } = [];
public int Attempts { get; set; }
public string MessageType { get; set; } = string.Empty;
public Envelope Read()
{
var envelope = EnvelopeSerializer.Deserialize(Body);
envelope.OwnerId = OwnerId;
envelope.Attempts = Attempts;
return envelope;
}
}