Я хочу проверить входящее сообщение, используя FluentValidation в моем случае, и в случае сбоя оно должно немедленно вернуться. Я просмотрел http://docs.masstransit-project.com/en/latest/usage/observers.html, и в моем случае мне нравится идея
public class ConsumeObserver : IConsumeObserver
{
Task IConsumeObserver.PreConsume<T>(ConsumeContext<T> context)
{
//1.Validate here
//2. If success go on to consumer
//3. If fails exit with the result of validation and don't go through consumer.
}
Task IConsumeObserver.PostConsume<T>(ConsumeContext<T> context)
{
}
Task IConsumeObserver.ConsumeFault<T>(ConsumeContext<T> context, Exception exception)
{
}
}
because I get the message already deserialized and so is easy to use the validator. The problem is that I don't know how to return without going through consumer and a the same time keep the validation errors.
Спасибо.