Explorar el Código

Fix type header null exception

master
Savorboard hace 4 años
padre
commit
4b9f03d2a0
Se han modificado 2 ficheros con 12 adiciones y 4 borrados
  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 Ver fichero

@@ -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 Ver fichero

@@ -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())


Cargando…
Cancelar
Guardar