Skip to content

Instantly share code, notes, and snippets.

@KevM
Created January 29, 2010 15:06
Show Gist options
  • Select an option

  • Save KevM/289778 to your computer and use it in GitHub Desktop.

Select an option

Save KevM/289778 to your computer and use it in GitHub Desktop.
Generic Masstransit Message Publisher/Sender
using Dovetail.Commons;
using MassTransit;
namespace Dovetail.Carrier.Core
{
public interface IMessagePublisher
{
void Publish<MESSAGE>(MESSAGE message) where MESSAGE : class;
}
public class MessagePublisher : IMessagePublisher
{
private readonly MessageBusSettings _messageBusSettings;
private readonly IEndpointFactory _endpointFactory;
public MessagePublisher(MessageBusSettings messageBusSettings, IEndpointFactory endpointFactory)
{
_messageBusSettings = messageBusSettings;
_endpointFactory = endpointFactory;
}
public void Publish<MESSAGE>(MESSAGE message) where MESSAGE : class
{
var queueName = _messageBusSettings.MessageQueue;
var messageEndpoint = _endpointFactory.GetEndpoint(queueName);
messageEndpoint.Send(message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment