Skip to content

Instantly share code, notes, and snippets.

@alexeyzimarev
Last active July 12, 2017 18:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Using this base class you can handle your messages without extracting them first from the context. Context is still available.
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