admin管理员组文章数量:1278910
I'm trying to use MassaTransit on a single queue (Azure) and dispatch the message to the correct IService based on the type but I'm unable.
If I use a string property called Type
and I switch over it, that's fine. Instead if I try to switch on the interface implementation it does not work.
Here's my snippet of code
public class KlaviyoMessageConsumer(IKlaviyoReviewSubmittedService klaviyoReviewSubmittedService)
: IConsumer<IKlaviyoBaseMessage>
{
public async Task Consume(ConsumeContext<IKlaviyoBaseMessage> context)
{
var messageType = context.Headers.Get<string>("MessageType"); //Using this workss
switch (context.Message)
{
case ReviewSubmittedRequestMessage reviewMessage:
await klaviyoReviewSubmittedService.SendReviewSubmittedEventAsync(
reviewMessage.ProductReviewGuid,context.CancellationToken);
break;
}
}
}
In the other app, the item is sent correctly
await endpoint.Send<ReviewSubmittedRequestMessage>( new
ReviewSubmittedRequestMessage
{
ProductReviewGuid = Guid.NewGuid(),
});
If I look at the type while running it's
{MassTransit.DynamicInternal.omiss.Packages.Contracts.MassTransit.Klaviyo.IKlaviyoBaseMessage}
Any suggestion? Thanks
本文标签: Using Interface in a MassTransit consume messageStack Overflow
版权声明:本文标题:Using Interface in a MassTransit consume message - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741248081a2365269.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论