我想使用独立的石英调度程序为状态机传奇重新设置消息调度。现在它适用于普通消费者,但是我无法正确设置重新传播。我的传奇配置如下所示:
MassTransit.Bus.Factory.CreateUsingRabbitMq(cfg =>
{
var retryPolicy = Retry.Incremental(5, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(2));
cfg.UseMessageScheduler(new Uri($"rabbitmq://localhost/SchedulerQueue"));
var host = cfg.Host(new Uri(uri), h =>
{
h.Username(config.RabbitMqUser);
h.Password(config.RabbitMqPassword);
});
cfg.ReceiveEndpoint(host, "SagaQueue", e =>
{
e.Durable = true;
e.StateMachineSaga(new MySaga(),
repository, c =>
{
c.UseTransaction();
c.Message<ISagaEvent>(y => y.UseScheduledRedelivery(retryPolicy));
});
});
});
其中ISagaEvent是由saga处理的消息。我做错了什么,有没有办法为传奇配置预定的重新传递?
答案 0 :(得分:2)
要在传奇中进行计划,通常最好使用实际的状态机计划功能,因此更新传奇的状态以指示重新传递。
基本上,如果您收到一个尚未准备好的状态的事件,请使用int main()
{
srand(static_cast<unsigned int>(time(0)));
int secretNumber = rand() % 64 + 1;
int tries = 0;
int High = 64;
int Low = 1;
int guess = rand() % High + Low;
cout << "\tWelcome to Guess My Number\n\n";
do {
int guess = rand() % High + Low;
++tries;
if (guess > secretNumber) {
cout << "Too high!\n\n";
cout << "\n"<<guess;
int High = guess - 1;
}
else if (guess < secretNumber) {
cout << "Too low!\n\n";
cout <<"\n"<< guess;
int Low = guess + 1;
}
else
{
cout << "\nThat's it!You got it in" << tries << "guesses!\n";
system("pause");
return 0;
}
} while (guess != secretNumber);
system("pause");
return 0;
}
在将来的某个时间安排该消息,此时该事件可能处于可能的状态处理。
文档中有一个好的计划示例: http://masstransit-project.com/MassTransit/advanced/sagas/automatonymous.html