【发布时间】:2022-08-19 23:15:44
【问题描述】:
我是 NServicebus 的新手,一直在努力在文档中找到答案。
我正在尝试接收一条以简单 JSON 格式发布到 Amazon SQS 的消息,如下所示:
\"MyMessage\": {
\"Id\": 1,
\"Name\": \"Name\",
\"Field1\": \"text\",
\"Field2\": 1,
\"Field3\": false
}
但是,每当这被发送到队列时,我的 NServicebus 订阅者都会说这是一条有毒消息,并且不会尝试处理它。
我意识到这条消息缺少很多 NServicebus 的东西,因为当我通过 NServicebus 发布消息时,它看起来像这样:
{
\"Headers\": {
\"NServiceBus.MessageId\": \"a244a014-e331-41e6-b6ca-aed6011af905\",
\"NServiceBus.MessageIntent\": \"Publish\",
\"NServiceBus.ConversationId\": \"e42f0308-4c51-4787-ade0-aed6011af90f\",
\"NServiceBus.CorrelationId\": \"a244a014-e331-41e6-b6ca-aed6011af905\",
\"NServiceBus.OriginatingMachine\": \"DESKTOP-1234567\",
\"NServiceBus.OriginatingEndpoint\": \"endpoint\",
\"$.diagnostics.originating.hostid\": \"da7dce712dfbc0f093aa30eb7f25d2b4\",
\"NServiceBus.ContentType\": \"application/json\",
\"NServiceBus.EnclosedMessageTypes\": \"Type\",
\"NServiceBus.Version\": \"7.7.3\",
\"NServiceBus.TimeSent\": \"2022-07-18 17:10:16:400164 Z\"
},
\"Body\": \"Base 64 encoded string here\",
\"S3BodyKey\": null
}
问题是我收到的消息不是通过 NServicebus 发布的,而是我上面显示的格式。它没有所有的标头和 base64 编码的正文。
有没有办法设置 NServicebus 能够接收和处理这样的消息?或者它只是不是为了处理这样的事情而设计的?
注意:这是一个 .Net 6 应用程序
编辑:我发现这篇文章提到了 NServicebus 如何在没有所有标题的情况下接收消息,但它没有提到如何。
https://www.bradjolicoeur.com/Article/nsb-features-message-headers
标签: c# .net-6.0 nservicebus