Created
February 25, 2012 03:10
-
-
Save logicbomb/1905604 to your computer and use it in GitHub Desktop.
MassTransit Bug
This file contains 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
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