ソースを参照

Fix type header null exception

master
Savorboard 4年前
コミット
4b9f03d2a0
2個のファイルの変更12行の追加4行の削除
  1. +1
    -1
      src/DotNetCore.CAP/Internal/ICapPublisher.Default.cs
  2. +11
    -3
      src/DotNetCore.CAP/Internal/IConsumerRegister.Default.cs

+ 1
- 1
src/DotNetCore.CAP/Internal/ICapPublisher.Default.cs ファイルの表示

@@ -71,7 +71,7 @@ namespace DotNetCore.CAP.Internal
var messageId = SnowflakeId.Default().NextId().ToString();
headers.Add(Headers.MessageId, messageId);
headers.Add(Headers.MessageName, name);
headers.Add(Headers.Type, typeof(T).FullName);
headers.Add(Headers.Type, typeof(T).Name);
headers.Add(Headers.SentTime, DateTimeOffset.Now.ToString());
if (!headers.ContainsKey(Headers.CorrelationId))
{


+ 11
- 3
src/DotNetCore.CAP/Internal/IConsumerRegister.Default.cs ファイルの表示

@@ -152,7 +152,7 @@ namespace DotNetCore.CAP.Internal
client.OnMessageReceived += async (sender, transportMessage) =>
{
_logger.MessageReceived(transportMessage.GetId(), transportMessage.GetName());
long? tracingTimestamp = null;
try
{
@@ -182,8 +182,16 @@ namespace DotNetCore.CAP.Internal
catch (Exception e)
{
transportMessage.Headers.Add(Headers.Exception, nameof(SerializationException) + "-->" + e.Message);
var dataUri = $"data:{transportMessage.Headers[Headers.Type]};base64," + Convert.ToBase64String(transportMessage.Body);
message = new Message(transportMessage.Headers, dataUri);
if (transportMessage.Headers.TryGetValue(Headers.Type, out var val))
{
var dataUri = $"data:{val};base64," + Convert.ToBase64String(transportMessage.Body);
message = new Message(transportMessage.Headers, dataUri);
}
else
{
var dataUri = "data:UnknownType;base64," + Convert.ToBase64String(transportMessage.Body);
message = new Message(transportMessage.Headers, dataUri);
}
}

if (message.HasException())


読み込み中…
キャンセル
保存