Browse Source

Fixes RabbitMQ federation plugin, some headers with object values cause cast exceptions. (#1036)

master
savorboard 3 years ago
parent
commit
f1500fd382
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs

+ 9
- 1
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs View File

@@ -176,11 +176,19 @@ namespace DotNetCore.CAP.RabbitMQ
private void OnConsumerReceived(object sender, BasicDeliverEventArgs e)
{
var headers = new Dictionary<string, string>();

if (e.BasicProperties.Headers != null)
{
foreach (var header in e.BasicProperties.Headers)
{
headers.Add(header.Key, header.Value == null ? null : Encoding.UTF8.GetString((byte[])header.Value));
if (header.Value is byte[] val)
{
headers.Add(header.Key, Encoding.UTF8.GetString(val));
}
else
{
headers.Add(header.Key, header.Value?.ToString());
}
}
}



Loading…
Cancel
Save