Last active
July 12, 2017 18:50
-
-
Save alexeyzimarev/ae92e6c486b8b360d764588fa44a990d to your computer and use it in GitHub Desktop.
Using this base class you can handle your messages without extracting them first from the context. Context is still available.
This file contains hidden or 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