Skip to content
This repository was archived by the owner on Aug 14, 2022. It is now read-only.
Peter Ritchie edited this page Jul 28, 2017 · 3 revisions

About

The Messaging.Primitives library provides primitive types (interfaces) to promote message/event-oriented design in .NET. The main goal is to facilitate a composable message-oriented application by separating the responsibilities of routing message from handling/processing messages.

Recipes

Reference Message

public class GetLastTradePriceCommand : IMessage
{
	/// <summary><seealso cref="IMessage.CorrelationId"/></summary>
	public string CorrelationId { get;set; }
	/// <summary>The symbol name whose last trace price to retrieve.</summary>
	public string Symbol { get; set; }
}

Handle a message

public class GetLastTradePriceCommandHandler : IConsumer<GetLastTradePriceCommand> where T : IMessage
{
	public void Handle(GetLastTradePriceCommand message)
	{
		// TODO: something with message
	}
}

Register a message handler with in-memory bus

public void RegisterMessageHandler(IBus bus, GetLastTradePriceCommandHandler handler)
{
	bus.AddHandler(handler);
}

Route message via bus

public void RouteMessage(IBus bus, GetLastTradePriceCommand command)
{
	bus.Handle(command);
}