private static async Task AsyncMain() { Console.Title = "FileSystem Transport: Application One"; var endpointConfigurationBuilder = new EndpointConfigurationBuilder(); var endpointConfiguration = endpointConfigurationBuilder.GetEndpointConfiguration <FileTransport>(Endpoints.EndpointOne, Endpoints.ErrorQueue); endpointConfiguration.DisableFeature <TimeoutManager>(); var endpointInstance = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false); try { for (var i = 0; i < 100; i++) { var messageA = new MessageA(); await endpointInstance.Send(Endpoints.EndpointTwo, messageA).ConfigureAwait(false); } Console.WriteLine(); Console.WriteLine("MessageA sent. Press any key to exit"); Console.ReadKey(); } finally { await endpointInstance.Stop().ConfigureAwait(false); } }
private static void StartProducer() { var endpointConfigurationBuilder = new EndpointConfigurationBuilder(); _producer = new WorkProducer(endpointConfigurationBuilder); new Thread(_producer.Run).Start(); }
private static void StartConsumer() { var endpointConfigurationBuilder = new EndpointConfigurationBuilder(); var endpointBuilder = new EndpointBuilder(endpointConfigurationBuilder); _consumer = new ActivePassiveEndpointInstance(endpointBuilder, new SqlServerDistributedLockManager()); _consumer.Start().Inline(); }
private static async Task AsyncMain() { Console.Title = "Callback Usage: Sender"; await Task.Delay(1000); var endpointConfigurationBuilder = new EndpointConfigurationBuilder(); var endpointConfiguration = endpointConfigurationBuilder.GetEndpointConfiguration(Endpoints.Sender, Endpoints.ErrorQueue); endpointConfiguration.MakeInstanceUniquelyAddressable("1"); var endpointInstance = await Endpoint.Start(endpointConfiguration); try { Console.WriteLine(); Console.WriteLine("Press 'E' to send a message with an enum return"); Console.WriteLine("Press 'I' to send a message with an int return"); Console.WriteLine("Press 'O' to send a message with an object return"); Console.WriteLine("Press any other key to exit"); while (true) { var key = Console.ReadKey().Key; Console.WriteLine(); switch (key) { case ConsoleKey.E: await SendEnumMessage(endpointInstance).ConfigureAwait(false); continue; case ConsoleKey.I: await SendIntMessage(endpointInstance).ConfigureAwait(false); continue; case ConsoleKey.O: await SendObjectMessage(endpointInstance).ConfigureAwait(false); continue; } return; } } finally { await endpointInstance.Stop().ConfigureAwait(false); } }
public async Task Start() { try { var connectionString = Environment.GetEnvironmentVariable("servicebus_connection_string"); var endpointConfiguration = new EndpointConfigurationBuilder(EndpointName, connectionString).Build(); // start the endpoint _endpoint = await Endpoint.Start(endpointConfiguration); log.Info("****************** Sales endpoint successfully started ******************"); } catch (Exception ex) { FailFast("Failed to start.", ex); } }
private void AddEndpoint(IServiceCollection services) { Log.Info("****************** Store website endpoint starting ******************"); var connectionString = Environment.GetEnvironmentVariable("servicebus_connection_string"); var endpointConfiguration = new EndpointConfigurationBuilder("store-web", connectionString) .AsSendOnly() .Build(); // start the endpoint var endpointInstance = Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult(); Log.Info("****************** Store website endpoint successfully started ******************"); // register endpoint instance with the IoC framework services.AddSingleton <IMessageSession>(endpointInstance); }
private static async Task AsyncMain() { Console.Title = "End to End Example: Client"; await Task.Delay(2000); var endpointConfigurationBuilder = new EndpointConfigurationBuilder(); var endpointConfiguration = endpointConfigurationBuilder.GetEndpointConfiguration(Endpoints.Client, auditQueue: null, errorQueue: Endpoints.ErrorQueue); var endpointInstance = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false); try { await SendOrder(endpointInstance); } finally { await endpointInstance.Stop().ConfigureAwait(false); } }
private static async Task AsyncMain() { Console.Title = "Pub/Sub: Publisher"; await Task.Delay(1000); var endpointConfigurationBuilder = new EndpointConfigurationBuilder(); var endpointConfiguration = endpointConfigurationBuilder.GetEndpointConfiguration(Endpoints.Publisher, Endpoints.ErrorQueue); var endpointInstance = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false); try { await Publish(endpointInstance); } finally { await endpointInstance.Stop().ConfigureAwait(false); } }
private static async Task AsyncMain() { Console.Title = "End to End Example: Subscriber"; var endpointConfigurationBuilder = new EndpointConfigurationBuilder(); var endpointConfiguration = endpointConfigurationBuilder.GetEndpointConfiguration(Endpoints.Subscriber, Endpoints.ErrorQueue); var endpointInstance = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false); try { Console.WriteLine(); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } finally { await endpointInstance.Stop().ConfigureAwait(false); } }
private static async Task AsyncMain() { Console.Title = "Pub/Sub: SubscriberOne"; var endpointConfigurationBuilder = new EndpointConfigurationBuilder(); var endpointConfiguration = endpointConfigurationBuilder.GetEndpointConfiguration(Endpoints.SubscriberOne, Endpoints.ErrorQueue); var endpointInstance = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false); await endpointInstance.Subscribe <EventMessage>().ConfigureAwait(false); try { Console.WriteLine(); Console.WriteLine("SubscriberOne Subscribed: Press any key to exit"); Console.ReadKey(); } finally { await endpointInstance.Stop().ConfigureAwait(false); } }
private static async Task AsyncMain() { Console.Title = "Callback Usage: Receiver"; var endpointConfigurationBuilder = new EndpointConfigurationBuilder(); var endpointConfiguration = endpointConfigurationBuilder.GetEndpointConfiguration(Endpoints.Receiver, Endpoints.ErrorQueue); endpointConfiguration.MakeInstanceUniquelyAddressable("1"); var endpointInstance = await Endpoint.Start(endpointConfiguration); try { Console.WriteLine(); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } finally { await endpointInstance.Stop().ConfigureAwait(false); } }