Asp.net core Masstransit RabbitMQ发布服务器无法发布“0”;“正确”;合同

Asp.net core Masstransit RabbitMQ发布服务器无法发布“0”;“正确”;合同,asp.net-core,properties,rabbitmq,asp.net-core-webapi,masstransit,Asp.net Core,Properties,Rabbitmq,Asp.net Core Webapi,Masstransit,我一直在使用Masstransit和RabbitMQ创建消息契约来支持两个.NET核心web API之间的通信,我偶然发现了以下内容 假设我在两个项目中都有以下指定的合同: public class Profile : BaseEntity { public string Name { get; set; } public string Description { get; set; } public bool IsActive { get; set; }

我一直在使用Masstransit和RabbitMQ创建消息契约来支持两个.NET核心web API之间的通信,我偶然发现了以下内容

假设我在两个项目中都有以下指定的合同:

public class Profile : BaseEntity
{
    public string Name { get; set; }

    public string Description { get; set; }

    public bool IsActive { get; set; }

    public DefaultMode Mode { get; set; }

    public string SuperMode { get; set; }

    public ExtraClient? Client { get; set; }
}
每当我发布消息时

await _publishEndPoint.Publish<Profile>(profileUpdate);
wait\u publishEndPoint.Publish(profileUpdate);
另一端(接收器/订户API上的使用者)只能获取基本类型字段,例如,名称描述IsActive

其余字段被解析为null,尽管我很清楚在发布之前profileUpdate的属性具有正确的值

有人遇到过类似的情况吗

是因为继承吗

亲切问候,

编辑#1:语法

编辑#2:发布更多信息

根据要求,这里是我的消费者类:

public class ProfileUpdateConsumer : IConsumer<Profile>
{
    private readonly IProfilesHub _profileHub;

    public ProfileUpdateConsumer(IProfilesHub profileHub)
    {
        _profileHub = profileHub;
    }

    public async Task Consume(ConsumeContext<Profile> context)
    {
        await _profileHub.BroadcastProfileUpdate(context.Message);
    }
}
public类ProfileUpdateConsumer:IConsumer
{
私有只读IProfilesHub\u profileHub;
公共配置文件UpdateConsumer(IProfilesHub配置文件中心)
{
_profileHub=profileHub;
}
公共异步任务使用(使用上下文)
{
wait_profileHub.BroadcastProfileUpdate(context.Message);
}
}
这是我的出版商课程:

公共类配置文件发布者:IPPublisher { 私有只读IPublishEndpoint _publishEndPoint

    public ProfilePublisher(IPublishEndpoint publishEndpoint)
    {
        _publishEndPoint = publishEndpoint;
    }

    public async Task PublishProfileUpdate(object profileUpdate)
    {
        await _publishEndPoint.Publish<Profile>(profileUpdate);
    }
}
public ProfilePublisher(IPublishEndpoint publishEndpoint)
{
_publishEndPoint=publishEndPoint;
}
公共异步任务PublishProfileUpdate(对象配置文件更新)
{
等待_publishEndPoint.Publish(profileUpdate);
}
}

我知道已经有一段时间了,但是对于任何可能遇到这种情况的人来说

在与@Chris Patterson讨论后

我手动将一种数据类型转换为另一种,并确保所有字段都存在


这是有效的,尽管我仍然对导致这种行为的原因感到困惑。

您是否共享了发布者和消费者都可以使用的所有类?@AlexeyZimarev是的,当然,消费者和发布者共享相同的类,但为了澄清这是一个共享项目,而不是共享类库。你认为这可能会影响它吗?如果你可以发布你正在发布的类,以及无法获取字段的消费者类,这会有所帮助。我猜您正在发布基本类型概要文件,因此子类消息类型不可用。但同样,代码在这里起作用。@ChrisPatterson我已经用更多的代码更新了,这足够了吗?为什么是对象<代码>公共异步任务PublishProfileUpdate(object profileUpdate)-这应该是PublishProfileUpdate(T update),其中T:Profile——不过为什么不只发布T呢?