I would like to setup message scheduling redelivering for state machine saga using standalone quartz scheduler. Now It works fine with plain consumer, but I can't setup redelivering for saga properly. My saga configuration looks like this :
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));
});
});
});
where ISagaEvent is message processed by saga. Am I doing something wrong, and is there a way to configure scheduled redelivery for saga at all?
To schedule within a saga, it's typically best to use the actual state machine schedule feature, so the state of the saga is updated to indicate redelivery.
Essentially, if you receive an event in a state that is not yet ready for it, use the Schedule()
to schedule the message for some time in the future when the saga may be in a state where it can be processed.
A good schedule example is in the documentation: http://masstransit-project.com/MassTransit/advanced/sagas/automatonymous.html