C# 使用依赖项注入时的消息分区器?

C# 使用依赖项注入时的消息分区器?,c#,masstransit,C#,Masstransit,在通过依赖项注入autofac注册消费者时,如何设置消息分区 cfg.ReceiveEndpoint(host, c => { c.LoadFrom(context); c.Durable = true; }); 所有消息都具有相同的标记接口 IDomainEvent<Guid> 我希望所有消息都

在通过依赖项注入autofac注册消费者时,如何设置消息分区

 cfg.ReceiveEndpoint(host, c =>
                    {
                        c.LoadFrom(context);
                        c.Durable = true;
                    });
所有消息都具有相同的标记接口

 IDomainEvent<Guid>
我希望所有消息都按照该接口的Id属性进行分区

我想试试这样的东西:

 c.Consumer<SomeViewConsumer>(context,ConfigurePartition<SomeViewConsumer>(partitioner));
 c.Consumer<SomeOtherViewConsumer>(context,ConfigurePartition<SomeOtherViewConsumer>(partitioner));


  private static Action<IConsumerConfigurator<TConsumer>> ConfigurePartition<TConsumer>(IPartitioner partitioner) where TConsumer : class
  {
        return n => n.Message<IDomainEvent<Guid>>(k => k.UsePartitioner(partitioner, consumeContext => consumeContext.Message.Id));
  }

这行得通吗?

没有自动执行的方法,因为必须知道消息类型才能配置返回分区键的分区器委托


我还担心在一个接收端点上消耗太多不同类型的消息,通过使用.LoadFrom自动从容器中提取它们。

我稍微改变了这个问题。那样行吗?行的。