diff --git a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs index ae574a4..f1542b1 100644 --- a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs +++ b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs @@ -12,7 +12,7 @@ namespace DotNetCore.CAP.Kafka private readonly KafkaOptions _kafkaOptions; private Consumer _consumerClient; - public event EventHandler MessageReceieved; + public event EventHandler MessageReceieved; public IDeserializer StringDeserializer { get; set; } @@ -65,8 +65,9 @@ namespace DotNetCore.CAP.Kafka private void ConsumerClient_OnMessage(object sender, Message e) { - var message = new MessageBase + var message = new MessageContext { + Group = _groupId, KeyName = e.Topic, Content = e.Value }; diff --git a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs index e21cc69..aced27f 100644 --- a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs +++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs @@ -17,7 +17,7 @@ namespace DotNetCore.CAP.RabbitMQ private IConnection _connection; private IModel _channel; - public event EventHandler MessageReceieved; + public event EventHandler MessageReceieved; public RabbitMQConsumerClient(string queueName, RabbitMQOptions options) { @@ -77,8 +77,9 @@ namespace DotNetCore.CAP.RabbitMQ private void OnConsumerReceived(object sender, BasicDeliverEventArgs e) { - var message = new MessageBase + var message = new MessageContext { + Group = _queueName, KeyName = e.RoutingKey, Content = Encoding.UTF8.GetString(e.Body) }; diff --git a/src/DotNetCore.CAP/Abstractions/ConsumerContext.cs b/src/DotNetCore.CAP/Abstractions/ConsumerContext.cs index ccbdf5b..7c8ece6 100644 --- a/src/DotNetCore.CAP/Abstractions/ConsumerContext.cs +++ b/src/DotNetCore.CAP/Abstractions/ConsumerContext.cs @@ -13,7 +13,7 @@ namespace DotNetCore.CAP.Abstractions /// /// consumer method descriptor. /// reveied message. - public ConsumerContext(ConsumerExecutorDescriptor descriptor, MessageBase message) + public ConsumerContext(ConsumerExecutorDescriptor descriptor, MessageContext message) { ConsumerDescriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor)); DeliverMessage = message ?? throw new ArgumentNullException(nameof(message)); @@ -27,6 +27,6 @@ namespace DotNetCore.CAP.Abstractions /// /// consumer reveived message. /// - public MessageBase DeliverMessage { get; set; } + public MessageContext DeliverMessage { get; set; } } } \ No newline at end of file diff --git a/src/DotNetCore.CAP/IConsumerClient.cs b/src/DotNetCore.CAP/IConsumerClient.cs index 2d93a2d..f3ddd61 100644 --- a/src/DotNetCore.CAP/IConsumerClient.cs +++ b/src/DotNetCore.CAP/IConsumerClient.cs @@ -14,6 +14,6 @@ namespace DotNetCore.CAP void Listening(TimeSpan timeout); - event EventHandler MessageReceieved; + event EventHandler MessageReceieved; } } \ No newline at end of file diff --git a/src/DotNetCore.CAP/Infrastructure/MessageBase.cs b/src/DotNetCore.CAP/Infrastructure/MessageContext.cs similarity index 65% rename from src/DotNetCore.CAP/Infrastructure/MessageBase.cs rename to src/DotNetCore.CAP/Infrastructure/MessageContext.cs index ecf3116..48982d6 100644 --- a/src/DotNetCore.CAP/Infrastructure/MessageBase.cs +++ b/src/DotNetCore.CAP/Infrastructure/MessageContext.cs @@ -1,7 +1,9 @@ namespace DotNetCore.CAP.Infrastructure { - public class MessageBase + public class MessageContext { + public string Group { get; set; } + public string KeyName { get; set; } public string Content { get; set; }