Przeglądaj źródła

Split Cap Message to CapSendMessage and CapReceivedMessage.

master
yangxiaodong 7 lat temu
rodzic
commit
b478b77d4d
6 zmienionych plików z 70 dodań i 69 usunięć
  1. +46
    -0
      src/DotNetCore.CAP/Infrastructure/CapMessage.cs
  2. +9
    -0
      src/DotNetCore.CAP/Infrastructure/CapReceivedMessage.cs
  3. +6
    -0
      src/DotNetCore.CAP/Infrastructure/CapSentMessage.cs
  4. +0
    -52
      src/DotNetCore.CAP/Infrastructure/ConsistencyMessage.cs
  5. +0
    -17
      src/DotNetCore.CAP/Infrastructure/DeliverMessage.cs
  6. +9
    -0
      src/DotNetCore.CAP/Infrastructure/MessageBase.cs

+ 46
- 0
src/DotNetCore.CAP/Infrastructure/CapMessage.cs Wyświetl plik

@@ -0,0 +1,46 @@
using System;

namespace DotNetCore.CAP.Infrastructure
{
/// <summary>
/// The default implementation of <see cref="ConsistencyMessage{TKey}"/> which uses a string as a primary key.
/// </summary>
public abstract class CapMessage : MessageBase
{
/// <summary>
/// Initializes a new instance of <see cref="CapMessage"/>.
/// </summary>
/// <remarks>
/// The Id property is initialized to from a new GUID string value.
/// </remarks>
public CapMessage()
{
Id = Guid.NewGuid().ToString();
Added = DateTime.Now;
}

public CapMessage(MessageBase message)
{
KeyName = message.KeyName;
Content = message.Content;
}

public string Id { get; set; }

public DateTime Added { get; set; }

public DateTime LastRun { get; set; }

public int Retries { get; set; }

public string StateName { get; set; }
}

public struct StateName
{
public const string Enqueued = nameof(Enqueued);
public const string Processing = nameof(Processing);
public const string Succeeded = nameof(Succeeded);
public const string Failed = nameof(Failed);
}
}

+ 9
- 0
src/DotNetCore.CAP/Infrastructure/CapReceivedMessage.cs Wyświetl plik

@@ -0,0 +1,9 @@
namespace DotNetCore.CAP.Infrastructure
{
public class CapReceivedMessage : CapMessage
{
public CapReceivedMessage(MessageBase baseMessage) : base(baseMessage)
{
}
}
}

+ 6
- 0
src/DotNetCore.CAP/Infrastructure/CapSentMessage.cs Wyświetl plik

@@ -0,0 +1,6 @@
namespace DotNetCore.CAP.Infrastructure
{
public class CapSentMessage : CapMessage
{
}
}

+ 0
- 52
src/DotNetCore.CAP/Infrastructure/ConsistencyMessage.cs Wyświetl plik

@@ -1,52 +0,0 @@
using System;

namespace DotNetCore.CAP.Infrastructure
{
/// <summary>
/// The default implementation of <see cref="ConsistencyMessage{TKey}"/> which uses a string as a primary key.
/// </summary>
public class ConsistencyMessage
{
/// <summary>
/// Initializes a new instance of <see cref="ConsistencyMessage"/>.
/// </summary>
/// <remarks>
/// The Id property is initialized to from a new GUID string value.
/// </remarks>
public ConsistencyMessage()
{
Id = Guid.NewGuid().ToString();
SendTime = DateTime.Now;
UpdateTime = SendTime;
Status = MessageStatus.WaitForSend;
}

public string Id { get; set; }

public DateTime SendTime { get; set; }

public string Topic { get; set; }

public string Payload { get; set; }

public MessageStatus Status { get; set; }

public virtual DateTime? UpdateTime { get; set; }

public byte[] RowVersion { get; set; }
}

/// <summary>
/// ConsistencyMessage consume status
/// </summary>
public enum MessageStatus
{
Deleted = 0,
WaitForSend = 1,
Processing = 2,
RollbackSuccessed = 3,
RollbackFailed = 4,
Successed = 5,
Received = 6
}
}

+ 0
- 17
src/DotNetCore.CAP/Infrastructure/DeliverMessage.cs Wyświetl plik

@@ -1,17 +0,0 @@
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; }
}
}

+ 9
- 0
src/DotNetCore.CAP/Infrastructure/MessageBase.cs Wyświetl plik

@@ -0,0 +1,9 @@
namespace DotNetCore.CAP.Infrastructure
{
public class MessageBase
{
public string KeyName { get; set; }

public string Content { get; set; }
}
}

Ładowanie…
Anuluj
Zapisz