[英]MassTransit RMQ scheduling scheduled but not sent
I'm trying to implement scheduling mechanism by the masstransit/rabbitmq
.我正在尝试通过masstransit/rabbitmq
实现调度机制。
I've added the configuration as stated in the docs:我添加了文档中所述的配置:
Uri schedulerEndpoint = new (Constants.MassTransit.SchedulerEndpoint);
services.AddMassTransit(mtConfiguration =>
{
mtConfiguration.AddMessageScheduler(schedulerEndpoint);
mtConfiguration.AddSagaStateMachine<ArcStateMachine, ArcProcess>(typeof(ArcSagaDefinition))
.Endpoint(e => e.Name = massTransitConfiguration.SagaQueueName)
.MongoDbRepository(mongoDbConfiguration.ConnectionString, r =>
{
r.DatabaseName = mongoDbConfiguration.DbName;
r.CollectionName = mongoDbConfiguration.CollectionName;
});
mtConfiguration.UsingRabbitMq((context, cfg) =>
{
cfg.UseMessageScheduler(schedulerEndpoint);
cfg.Host(new Uri(rabbitMqConfiguration.Host), hst =>
{
hst.Username(rabbitMqConfiguration.Username);
hst.Password(rabbitMqConfiguration.Password);
});
cfg.ConfigureEndpoints(context);
});
});
Then I'm sending a scheduled message using the Bus
:然后我使用Bus
发送预定消息:
DateTime messageScheduleTime = DateTime.UtcNow + TimeSpan.FromMinutes(1);
await _MessageScheduler.SchedulePublish<ScheduledMessage>(messageScheduleTime, new
{
ActivationId = context.Data.ActivationId
});
_MessageCheduler
is the IMessageScheduler
instance. _MessageCheduler
是IMessageScheduler
实例。
I do see the Scheduler queue receive the scheduled message and I see the correct scheduledTime
property in it but the message does not reach the state machine whenever its schedule should fire.我确实看到调度程序队列收到了预定的消息,并且我在其中看到了正确的scheduledTime
属性,但是只要它的调度应该触发,该消息就不会到达 state 机器。 Seems like I'm missing something in the configuration or some MassTransit service that is not started.好像我在配置中遗漏了一些东西,或者一些没有启动的 MassTransit 服务。
Please, assist.请协助。
If you actually read the documentation you would see that UseDelayedMessageScheduler
is the proper configuration to use RabbitMQ for scheduling.如果您实际阅读文档,您会发现UseDelayedMessageScheduler
是使用 RabbitMQ 进行调度的正确配置。 And AddDelayedMessageScheduler
for the container-based IMessageScheduler
registration.并且AddDelayedMessageScheduler
用于基于容器的IMessageScheduler
注册。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.