Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hbulens/d35a0ef8a3fa02a202830fda37f069b0 to your computer and use it in GitHub Desktop.
Save hbulens/d35a0ef8a3fa02a202830fda37f069b0 to your computer and use it in GitHub Desktop.
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