MassTransit - where to store state between attempts

I am using MassTransit (and RabbitMq for queues) to perform sequential processing of each message, which involves several steps.

I want to be able to store the "process-state" information somewhere in IConsumeContext<MyMessage>

that will be associated with each specific message, so for example if processing the message fails in step 2, on the next try I would go to step 2 and do not repeat step 1 again.

Is it possible?

Some possible ways I see is to change the message itself, but I don't know if this is the standard way of doing things.

Also, the post has a property Headers

, but I'm not sure what it is for.

Has anyone done this before?

UPDATE:

I could just use blocks try/catch

with loops and a delay inside, but I don't know if it would be better to avoid that.

+3


source to share


1 answer


The best way to deal with something like this is through Automatonymous saga . Make retries explicit and part of your domain.



We are already retrying at a lower level if an exception is thrown, which it casts back to the queue and retries until the maximum number of retries is reached. The message is then placed on the error queue. You can also call RetryLater()

in context. There's a repeat count in the header for things like counting repetitions.

+2


source







All Articles