我以这种方式注册后发布了一条消息(评论行做了很多尝试)。我传递了一个 queuePrefix 以使用不同的开发空间,每个开发人员一个,因为应用程序是基于微服务的。Masstransit 将不同微服务的信息交换解耦
this IServiceBusBusFactoryConfigurator cfg, IServiceProvider provider, string queuePrefix = null,
Action<IConsumerConfigurator<TConsumer>> configure = null)
where TConsumer : class, IConsumer<TCommand>
where TCommand : class
{
string queueName = $"{queuePrefix}-{typeof(TCommand).Name}";
cfg.Message<TCommand>(configureTopology => {
//configureTopology.SetEntityName(queueName);
//configureTopology.UsePartitionKeyFormatter(context => context.Message.CustomerId);
});
cfg.Publish<TCommand>(configureTopology => {
configureTopology.EnablePartitioning = true;
//configureTopology.UsePartitionKeyFormatter(context => context.Message.CustomerId);
});
cfg.Send<TCommand>(x =>
{
//x.UsePartitionKeyFormatter(context => context..Message.CustomerId);
});
cfg.ReceiveEndpoint(queueName, endpointCfg =>
{
endpointCfg.RemoveSubscriptions = true;
endpointCfg.EnablePartitioning = true;
endpointCfg.Consumer<TConsumer>(provider, configure);
});
return cfg;
}
我虽然前缀就足够了,但是如果我发布一条消息,所有的开发空间都会消耗这条消息。我该怎么办?我试过订阅但没有成功。看来我走错了路