2021-11-28 13:18:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace PettingZoo.Core.Connection
|
|
|
|
|
{
|
2021-12-06 13:08:29 +00:00
|
|
|
|
public class BaseMessageInfo
|
2021-11-28 13:18:21 +00:00
|
|
|
|
{
|
|
|
|
|
public string Exchange { get; }
|
|
|
|
|
public string RoutingKey { get; }
|
|
|
|
|
public byte[] Body { get; }
|
2021-12-06 13:08:29 +00:00
|
|
|
|
public MessageProperties Properties { get; }
|
2021-11-28 13:18:21 +00:00
|
|
|
|
|
2021-12-06 13:08:29 +00:00
|
|
|
|
public BaseMessageInfo(string exchange, string routingKey, byte[] body, MessageProperties properties)
|
2021-11-28 13:18:21 +00:00
|
|
|
|
{
|
|
|
|
|
Exchange = exchange;
|
|
|
|
|
RoutingKey = routingKey;
|
|
|
|
|
Body = body;
|
|
|
|
|
Properties = properties;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-06 13:08:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ReceivedMessageInfo : BaseMessageInfo
|
|
|
|
|
{
|
|
|
|
|
public DateTime ReceivedTimestamp { get; }
|
|
|
|
|
|
|
|
|
|
public ReceivedMessageInfo(string exchange, string routingKey, byte[] body, MessageProperties properties, DateTime receivedTimestamp)
|
|
|
|
|
: base(exchange, routingKey, body, properties)
|
|
|
|
|
{
|
|
|
|
|
ReceivedTimestamp = receivedTimestamp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class PublishMessageInfo : BaseMessageInfo
|
|
|
|
|
{
|
|
|
|
|
public PublishMessageInfo(string exchange, string routingKey, byte[] body, MessageProperties properties)
|
|
|
|
|
: base(exchange, routingKey, body, properties)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public enum MessageDeliveryMode
|
|
|
|
|
{
|
|
|
|
|
NonPersistent = 1,
|
|
|
|
|
Persistent = 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class MessageProperties
|
|
|
|
|
{
|
|
|
|
|
private static readonly IReadOnlyDictionary<string, string> EmptyHeaders = new Dictionary<string, string>();
|
|
|
|
|
|
|
|
|
|
public MessageProperties(IReadOnlyDictionary<string, string>? headers)
|
|
|
|
|
{
|
|
|
|
|
Headers = headers ?? EmptyHeaders;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string? AppId { get; init; }
|
|
|
|
|
public string? ContentEncoding { get; init; }
|
|
|
|
|
public string? ContentType { get; init; }
|
|
|
|
|
public string? CorrelationId { get; init; }
|
|
|
|
|
public MessageDeliveryMode? DeliveryMode { get; init; }
|
|
|
|
|
public string? Expiration { get; init; }
|
|
|
|
|
public IReadOnlyDictionary<string, string> Headers { get; }
|
|
|
|
|
public string? MessageId { get; init; }
|
|
|
|
|
public byte? Priority { get; init; }
|
|
|
|
|
public string? ReplyTo { get; init; }
|
|
|
|
|
public DateTime? Timestamp { get; init; }
|
|
|
|
|
public string? Type { get; init; }
|
|
|
|
|
public string? UserId { get; init; }
|
|
|
|
|
}
|
2021-11-28 13:18:21 +00:00
|
|
|
|
}
|