Skip to content

Instantly share code, notes, and snippets.

@logicbomb
Created February 25, 2012 03:10
Show Gist options
  • Save logicbomb/1905604 to your computer and use it in GitHub Desktop.
Save logicbomb/1905604 to your computer and use it in GitHub Desktop.
MassTransit Bug
public interface ICommandPublisher
{
void Publish(ICommand command);
}
public class MassTransitCommandPublisher : ICommandPublisher, ILoggingSource
{
public void Publish(ICommand command)
{
this.Debug("Publishing command {0}", command.GetType().Name);
Bus.Instance.Publish(command);
}
}
class Program
{
static void Main(string[] args)
{
Bus.Initialize(sbc =>
{
sbc.UseMsmq();
sbc.VerifyMsmqConfiguration();
sbc.UseMulticastSubscriptionClient();
sbc.ReceiveFrom(queueAddress);
sbc.SetPurgeOnStartup(true);
sbc.Subscribe(
s =>
{
s.Handler<DiagnosticCommand>(msg => this.Info(msg.Text));
});
});
Console.Clear();
Bus.Instance.Publish(new DiagnosticCommand {Text = "WORKS! publish DiagnosticCommand directly to Bus.Instance"});
var publisher = new MassTransitCommandPublisher();
publisher.Publish(new DiagnosticCommand() {Text = "NOPE! publish DiagnosticCommand to bus via ICommandPublisher"});
this.Debug("Published command through publisher");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment