RawRabbit icon indicating copy to clipboard operation
RawRabbit copied to clipboard

PublishAsync fails with PublishConfirmException if anonymous type is used

Open ChristianSauer opened this issue 7 years ago • 1 comments

Sample code:

` [DataContract] public class EmailRequest { [DataMember] public string UserId { get; set; }

    [DataMember]
    public string TemplateName { get; set; }

    [DataMember]
    public Dictionary<string, object> Variables { get; set; }
}
    {
        var message = new EmailRequest()
        {
            UserId = userId,
            TemplateName = templateName,
            Variables = new Dictionary<string, object>()
            {
                {"id", calculationId},
                {"calculation", calculationName}
            }
        };

        await _busClient.PublishAsync(message, ctx => ctx
            .UsePublishConfiguration(cfg => cfg
                .WithRoutingKey("email.send")
                .OnExchange("fastgenomics")));`

This will work, but using this fails with a PublishConfirmException:

` { var message = new { UserId = userId, TemplateName = templateName, Variables = new Dictionary<string, object>() { {"id", calculationId}, {"calculation", calculationName} } };

        await _busClient.PublishAsync(message, ctx => ctx
            .UsePublishConfiguration(cfg => cfg
                .WithRoutingKey("email.send")
                .OnExchange("fastgenomics")));`

ChristianSauer avatar Oct 18 '18 13:10 ChristianSauer

Thanks for reporting this. I wonder if there is something else going wrong causing the exception to be thrown. Could you try to do the same, but make sure that the exchange fastgenomics isn't declared? It would also be helpful if you could create a unit test that demonstrates the issue. Thanks!

pardahlman avatar Nov 04 '18 13:11 pardahlman