diff --git a/src/RawRabbit.Operations.Publish/PublishMessageExtension.cs b/src/RawRabbit.Operations.Publish/PublishMessageExtension.cs index 6f015819..265fc18f 100644 --- a/src/RawRabbit.Operations.Publish/PublishMessageExtension.cs +++ b/src/RawRabbit.Operations.Publish/PublishMessageExtension.cs @@ -23,8 +23,7 @@ public static class PublishMessageExtension .Use(StageMarkerOptions.For(PublishStage.MessageSerialized)) .Use(new BasicPropertiesOptions { PostCreateAction = (ctx, props) => { - props.Type = ctx.GetMessageType().GetUserFriendlyName(); - props.Headers.TryAdd(PropertyHeaders.Sent, DateTime.UtcNow.ToString("u")); + props.Headers.TryAdd(PropertyHeaders.Sent, DateTime.UtcNow.ToString("O")); }}) .Use(StageMarkerOptions.For(StageMarker.BasicPropertiesCreated)) .Use() diff --git a/src/RawRabbit.Operations.Request/RequestExtension.cs b/src/RawRabbit.Operations.Request/RequestExtension.cs index 0077d878..069f7d5b 100644 --- a/src/RawRabbit.Operations.Request/RequestExtension.cs +++ b/src/RawRabbit.Operations.Request/RequestExtension.cs @@ -34,7 +34,7 @@ public static class RequestExtension PostCreateAction = (ctx, props) => { props.Type = ctx.GetRequestMessageType().GetUserFriendlyName(); - props.Headers.TryAdd(PropertyHeaders.Sent, DateTime.UtcNow.ToString("u")); + props.Headers.TryAdd(PropertyHeaders.Sent, DateTime.UtcNow.ToString("O")); } }) .Use(StageMarkerOptions.For(StageMarker.BasicPropertiesCreated)) diff --git a/src/RawRabbit/Configuration/BasicPublish/BasicPublishConfigurationFactory.cs b/src/RawRabbit/Configuration/BasicPublish/BasicPublishConfigurationFactory.cs index 8762f40b..20f6eff6 100644 --- a/src/RawRabbit/Configuration/BasicPublish/BasicPublishConfigurationFactory.cs +++ b/src/RawRabbit/Configuration/BasicPublish/BasicPublishConfigurationFactory.cs @@ -12,11 +12,13 @@ public class BasicPublishConfigurationFactory : IBasicPublishConfigurationFactor { private readonly INamingConventions _conventions; private readonly ISerializer _serializer; + private readonly RawRabbitConfiguration _config; - public BasicPublishConfigurationFactory(INamingConventions conventions, ISerializer serializer) + public BasicPublishConfigurationFactory(INamingConventions conventions, ISerializer serializer, RawRabbitConfiguration config) { _conventions = conventions; _serializer = serializer; + _config = config; } public virtual BasicPublishConfiguration Create(object message) @@ -69,6 +71,11 @@ protected virtual IBasicProperties GetBasicProperties(Type type) return new BasicProperties { Type = type.GetUserFriendlyName(), + MessageId = Guid.NewGuid().ToString(), + DeliveryMode = _config.PersistentDeliveryMode ? Convert.ToByte(2) : Convert.ToByte(1), + ContentType = _serializer.ContentType, + ContentEncoding = "UTF-8", + UserId = _config.Username, Headers = new Dictionary() }; } diff --git a/src/RawRabbit/Serialization/ISerializer.cs b/src/RawRabbit/Serialization/ISerializer.cs index 8d34980f..a98d6ac0 100644 --- a/src/RawRabbit/Serialization/ISerializer.cs +++ b/src/RawRabbit/Serialization/ISerializer.cs @@ -4,6 +4,7 @@ namespace RawRabbit.Serialization { public interface ISerializer { + string ContentType { get; } string Serialize(object obj); object Deserialize(Type type, string str); TType Deserialize(string str); diff --git a/src/RawRabbit/Serialization/JsonSerializer.cs b/src/RawRabbit/Serialization/JsonSerializer.cs index b72091ad..3d0f7b10 100644 --- a/src/RawRabbit/Serialization/JsonSerializer.cs +++ b/src/RawRabbit/Serialization/JsonSerializer.cs @@ -7,6 +7,7 @@ namespace RawRabbit.Serialization public class JsonSerializer : ISerializer { private readonly Newtonsoft.Json.JsonSerializer _json; + public string ContentType => "application/json"; public JsonSerializer(Newtonsoft.Json.JsonSerializer json) { @@ -46,5 +47,7 @@ public TType Deserialize(string str) { return (TType)Deserialize(typeof(TType), str); } + + } }