Skip to content
This repository was archived by the owner on Sep 22, 2023. It is now read-only.
This repository was archived by the owner on Sep 22, 2023. It is now read-only.

HeaderBinding throwing on number values #5

@TietoOliverKurowski

Description

@TietoOliverKurowski

Hi,

Thanks for the great library!

I run into a problem with the header binding. When it deserializes a message with a header binding of type 'long' it throws in certain scenarios:

public class StockDataUpdateMessage
{
    [MessageHeader("timestamp"), IgnoreDataMember]
    public long Timestamp { get; set; }
}

If I send a message with this header and type 'string', everything works fine:
image

If I send a message with this header and type 'number', it throws an exception:
image

Here is the exception, it happens when the message is first deserialized:

System.InvalidCastException: Unable to cast object of type 'System.Int64' to type 'System.Byte[]'.
at EasyNetQ.MetaData.Bindings.HeaderBinding.FromMessageMetaData(MessageProperties source, Object destination)
at System.Collections.Generic.List1.ForEach(Action1 action)
at EasyNetQ.MetaData.MetaDataMessageSerializationStrategy.DeserializeMessage(MessageProperties properties, Byte[] body)
at EasyNetQ.RabbitAdvancedBus.<>c__DisplayClass17_0.b__0(Byte[] body, MessageProperties properties, MessageReceivedInfo messageReceivedInfo)
at EasyNetQ.RabbitAdvancedBus.<>c__DisplayClass21_0.b__0(Byte[] body, MessageProperties properties, MessageReceivedInfo receivedInfo)
at EasyNetQ.Consumer.HandlerRunner.InvokeUserMessageHandlerInternalAsync(ConsumerExecutionContext context)

What are your recommendations to handle the situation?
Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions