public Message ToMessage(object payload, MessageProperties messageProperties) { if (!(payload is IMessage)) { throw new ArgumentException("Could not convert [" + payload + "] - only [ IMessage ] is handled by this converter"); } var input = (IMessage)payload; var amqpMessage = PayloadConverter.ToMessage(input.Payload, messageProperties); HeaderMapper.FromHeaders(input.Headers, messageProperties); return(amqpMessage); }