Skip to content

Instantly share code, notes, and snippets.

@phatboyg
Created June 11, 2013 16:20
Show Gist options
  • Save phatboyg/5758302 to your computer and use it in GitHub Desktop.
Save phatboyg/5758302 to your computer and use it in GitHub Desktop.
This is an example of a convention-based consumer with no dependencies on MassTransit.
public class FreeConsumer
{
public event EventHandler<MyPublishedEvent> MyPublish;
public void CommandHandler(MyCommand command)
{
// process the command
// the event handler will be bound by MT to publish the event handler message type
MyPublish(this, new MyPublishedEvent(...));
}
// Request is a message type being consumed, Response is a message type being sent back
public Response RequestHandler(Request request)
{
// process the request
// will be sent via context.Respond to the requester
return new Response(...);
}
// all thrown exceptions are returned as Fault<T>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment