Commit b478b77d authored by yangxiaodong's avatar yangxiaodong

Split Cap Message to CapSendMessage and CapReceivedMessage.

parent fb8745ca
...@@ -5,48 +5,42 @@ namespace DotNetCore.CAP.Infrastructure ...@@ -5,48 +5,42 @@ namespace DotNetCore.CAP.Infrastructure
/// <summary> /// <summary>
/// The default implementation of <see cref="ConsistencyMessage{TKey}"/> which uses a string as a primary key. /// The default implementation of <see cref="ConsistencyMessage{TKey}"/> which uses a string as a primary key.
/// </summary> /// </summary>
public class ConsistencyMessage public abstract class CapMessage : MessageBase
{ {
/// <summary> /// <summary>
/// Initializes a new instance of <see cref="ConsistencyMessage"/>. /// Initializes a new instance of <see cref="CapMessage"/>.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// The Id property is initialized to from a new GUID string value. /// The Id property is initialized to from a new GUID string value.
/// </remarks> /// </remarks>
public ConsistencyMessage() public CapMessage()
{ {
Id = Guid.NewGuid().ToString(); Id = Guid.NewGuid().ToString();
SendTime = DateTime.Now; Added = DateTime.Now;
UpdateTime = SendTime;
Status = MessageStatus.WaitForSend;
} }
public string Id { get; set; } public CapMessage(MessageBase message)
{
public DateTime SendTime { get; set; } KeyName = message.KeyName;
Content = message.Content;
}
public string Topic { get; set; } public string Id { get; set; }
public string Payload { get; set; } public DateTime Added { get; set; }
public MessageStatus Status { get; set; } public DateTime LastRun { get; set; }
public virtual DateTime? UpdateTime { get; set; } public int Retries { get; set; }
public byte[] RowVersion { get; set; } public string StateName { get; set; }
} }
/// <summary> public struct StateName
/// ConsistencyMessage consume status
/// </summary>
public enum MessageStatus
{ {
Deleted = 0, public const string Enqueued = nameof(Enqueued);
WaitForSend = 1, public const string Processing = nameof(Processing);
Processing = 2, public const string Succeeded = nameof(Succeeded);
RollbackSuccessed = 3, public const string Failed = nameof(Failed);
RollbackFailed = 4,
Successed = 5,
Received = 6
} }
} }
\ No newline at end of file
namespace DotNetCore.CAP.Infrastructure
{
public class CapReceivedMessage : CapMessage
{
public CapReceivedMessage(MessageBase baseMessage) : base(baseMessage)
{
}
}
}
\ No newline at end of file
namespace DotNetCore.CAP.Infrastructure
{
public class CapSentMessage : CapMessage
{
}
}
\ No newline at end of file
namespace DotNetCore.CAP.Infrastructure
{
public class DeliverMessage
{
/// <summary>
/// Kafka 对应 Topic name
/// <para>
/// RabbitMQ 对应 RoutingKey
/// </para>
/// </summary>
public string MessageKey { get; set; }
public byte[] Body { get; set; }
public string Value { get; set; }
}
}
\ No newline at end of file
namespace DotNetCore.CAP.Infrastructure
{
public class MessageBase
{
public string KeyName { get; set; }
public string Content { get; set; }
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment