-
-
Save TravisTheTechie/1906347 to your computer and use it in GitHub Desktop.
MassTransit Bug
This file contains hidden or 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<T>(T command) where T : ICommand; | |
} | |
public class MassTransitCommandPublisher : ICommandPublisher, ILoggingSource | |
{ | |
public void Publish<T>(T command) where T : ICommand | |
{ | |
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