Permalink
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (45 sloc) 1.72 KB
using System;
using System.Threading.Tasks;
using NServiceBus;
class Program
{
static async Task Main()
{
Console.Title = "Samples.ASBS.SendReply.Endpoint1";
#region config
var endpointConfiguration = new EndpointConfiguration("Samples.ASBS.SendReply.Endpoint1");
endpointConfiguration.SendFailedMessagesTo("error");
endpointConfiguration.EnableInstallers();
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
var connectionString = Environment.GetEnvironmentVariable("AzureServiceBus_ConnectionString");
if (string.IsNullOrWhiteSpace(connectionString))
{
throw new Exception("Could not read the 'AzureServiceBus_ConnectionString' environment variable. Check the sample prerequisites.");
}
transport.ConnectionString(connectionString);
#endregion
var endpointInstance = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
Console.WriteLine("Press 'enter' to send a message");
Console.WriteLine("Press any other key to exit");
while (true)
{
var key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
break;
}
var orderId = Guid.NewGuid();
var message = new Message1
{
Property = "Hello from Endpoint1"
};
await endpointInstance.Send("Samples.ASBS.SendReply.Endpoint2", message)
.ConfigureAwait(false);
Console.WriteLine("Message1 sent");
}
await endpointInstance.Stop()
.ConfigureAwait(false);
}
}