Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using NServiceBus;
using hbulens.ServiceBus.Messages;
namespace hbulens.ServiceBus.Publisher
{
class Program
{
static void Main()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("hbulens.ServiceBus.Publisher");
busConfiguration.UseSerialization < JsonSerializer > ();
busConfiguration.UsePersistence < InMemoryPersistence > ();
busConfiguration.EnableInstallers();
using(IBus bus = Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press enter to send a message");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
break;
}
OrderMessage placeOrder = new OrderMessage
{
Description = "TEST", Id = Guid.NewGuid()
};
bus.Publish(placeOrder);
Console.WriteLine("Sent a new message with id: {0}", placeOrder.Id.ToString());
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.