Using this base class you can handle your messages without extracting them first from the context. Context is still available.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Threading.Tasks; | |
using MassTransit; | |
namespace Demo.MassTransit | |
{ | |
public abstract class BaseHandler<T> : IConsumer<T> where T : class | |
{ | |
protected ConsumeContext<T> Context { get; private set; } | |
public abstract Task Handle(T message); | |
public Task Consume(ConsumeContext<T> context) | |
{ | |
Context = context; | |
return Handle(context.Message); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment