private static async Task SendRequest() { var semaphoreSlim = new SemaphoreSlim(0, 1); IBusControl bus = null; await Task.Factory.StartNew(async() => { var queueGuid = Guid.NewGuid().ToString(); var models = new List <CorrelationResponseModel>(); var correlationConsumer = new CorrelationConsumer(model => { Console.WriteLine($"added model with index: {model.ResponseIndex}"); models.Add(model); if (models.Count == model.TotalCount) { Console.WriteLine("Got all models in list"); semaphoreSlim.Release(); } }); bus = Bus.Factory.CreateUsingAzureServiceBus(cfg => { AzureServiceBusFactory.ConfigureHost(cfg); cfg.ReceiveEndpoint(queueGuid, configurator => { configurator.Consumer(() => correlationConsumer); }); }); await bus.StartAsync(); await QueuePublisher.StartCorrelation(queueGuid); // Do not stop bus here, otherwise the consumer does not receive notifications // await bus.StopAsync(); }).ConfigureAwait(false); await semaphoreSlim.WaitAsync(); await bus?.StopAsync(); /* * var result = await RpcPublisher.SendToCoreRpcQueue(new StringIntRequestModel * { * IntValue = _intValue++, StringValue = "FrameworkRpcCall" * }); * * Console.WriteLine( * $"{Environment.NewLine}string: {result.StringValue}, int: {result.IntValue}, date: {result.DateTime}{Environment.NewLine}"); */ }
public bool Stop(HostControl hostControl) { bus?.StopAsync(new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token); return(true); }
public async Task Should_complete_running_consumers_nicely() { TaskCompletionSource <PingMessage> consumerStarted = GetTask <PingMessage>(); IBusControl bus = Bus.Factory.CreateUsingRabbitMq(x => { IRabbitMqHost host = x.Host("localhost", "test", h => { }); x.ReceiveEndpoint(host, "input_queue", e => { e.PurgeOnStartup = true; e.Handler <PingMessage>(async context => { await Console.Out.WriteLineAsync("Starting handler"); consumerStarted.TrySetResult(context.Message); for (var i = 0; i < 5; i++) { await Task.Delay(1000); await Console.Out.WriteLineAsync("Handler processing"); } await context.RespondAsync(new PongMessage(context.Message.CorrelationId)); await Console.Out.WriteLineAsync("Handler complete"); }); }); }); await Console.Out.WriteLineAsync("Starting bus"); await bus.StartAsync(TestCancellationToken); await Console.Out.WriteLineAsync("Bus started"); try { await bus.Publish(new PingMessage(), x => { x.RequestId = NewId.NextGuid(); x.ResponseAddress = bus.Address; }); await consumerStarted.Task; await Console.Out.WriteLineAsync("Consumer Start Acknowledged"); } finally { await Console.Out.WriteLineAsync("Stopping bus"); await bus.StopAsync(TestCancellationToken); await Console.Out.WriteLineAsync("Bus stopped"); } }
public Task StopAsync(CancellationToken cancellationToken) { _logger.LogInformation("Stopping bus Order Services"); return(_bus.StopAsync(cancellationToken)); }
public async Task StopAsync(CancellationToken cancellationToken) { _logger.LogDebug("Stopping host"); await _bus.StopAsync(cancellationToken).ConfigureAwait(false); }
public Task StopAsync(CancellationToken cancellationToken) { _timer?.Dispose(); return(_busControl.StopAsync(cancellationToken)); }
/// <summary> /// Stop a bus, throwing an exception if the bus does not stop. /// It is a wrapper of the async method `StopAsync` /// </summary> /// <param name="busControl">The bus handle</param> public static void Stop(this IBusControl busControl) { TaskUtil.Await(() => busControl.StopAsync()); }
public Task StopAsync(CancellationToken cancellationToken) { _logger.LogInformation("Bus is stopping..."); return(_bus.StopAsync(cancellationToken)); }
public override Task StopAsync(CancellationToken cancellationToken) { return(Task.WhenAll(base.StopAsync(cancellationToken), _bus.StopAsync())); }
/// <summary> /// Stop a bus, throwing an exception if the bus does not stop in the specified timeout /// </summary> /// <param name="bus">The bus handle</param> /// <param name="stopTimeout">The wait time before throwing an exception</param> public static async Task StopAsync(this IBusControl bus, TimeSpan stopTimeout) { using var cancellationTokenSource = new CancellationTokenSource(stopTimeout); await bus.StopAsync(cancellationTokenSource.Token).ConfigureAwait(false); }
public Task StopAsync(CancellationToken token = default) => _busControl.StopAsync(token);
public Task StopAsync(CancellationToken cancellationToken) { _log.LogInformation("Stopping bus..."); return(_busControl.StopAsync(cancellationToken)); }
public async Task StopAsync(CancellationToken cancellationToken) { await _bus.StopAsync(cancellationToken).ConfigureAwait(false); }
public async Task StopAsync(CancellationToken cancellationToken) { await _busControl.StopAsync(cancellationToken); _logger.LogInformation("Indexing service stopped"); }
public Task StopAsync(TimeSpan stopTimeout) { return(busControl.StopAsync(stopTimeout)); }
public async Task StopAsync(CancellationToken cancellationToken) { await _bus.StopAsync(cancellationToken).ConfigureAwait(false); _simplifiedBusCheck?.ReportBusStopped(); }
public override Task StopAsync(CancellationToken cancellationToken) { Console.WriteLine("BusService stopped"); return(_busControl.StopAsync(cancellationToken)); }
public Task StopAsync(CancellationToken cancellationToken) { return(bus.StopAsync(cancellationToken)); }
public virtual Task StopAsync(CancellationToken token = default(CancellationToken)) { return(_busControl.StopAsync(token)); }
/// <inheritdoc /> public override async Task StopAsync(CancellationToken cancellationToken) { await _busControl.StopAsync(cancellationToken); }
public Task StopAsync(CancellationToken cancellationToken) { logger.LogInformation($"Bus parado às {DateTimeOffset.Now}"); return(busControl.StopAsync(cancellationToken)); }
public async Task StopAsync(CancellationToken cancellationToken) { //stop the bus await busControl.StopAsync(TimeSpan.FromSeconds(10)); }
public async Task StopAsync(CancellationToken cancellationToken) { await _bus.StopAsync(cancellationToken); }
public override async Task StopAsync(CancellationToken cancellationToken) { await _bus.StopAsync(cancellationToken); await base.StopAsync(cancellationToken); }
public async Task CloseAsync() => await _bus?.StopAsync();
public Task StopAsync(CancellationToken cancellationToken) { return(_busControl.StopAsync(cancellationToken)); }
public async Task StopAsync(CancellationToken cancellationToken) { await _busControl.StopAsync(cancellationToken); _logger.LogInformation("发货 微服务已停止"); }
public async Task StopAsync(CancellationToken cancellationToken) { await busControl.StopAsync(cancellationToken); }
public Task StopAsync(CancellationToken cancellationToken) => _busControl.StopAsync(cancellationToken);
public async Task SetupAzureServiceBusTestFixture() { _bus = CreateBus(); _bus.ConnectReceiveEndpointObserver(new ReceiveEndpointObserver()); _busHandle = await _bus.StartAsync(); try { _busSendEndpoint = await _bus.GetSendEndpoint(_bus.Address); _busSendEndpoint.ConnectSendObserver(_sendObserver); _inputQueueSendEndpoint = await _bus.GetSendEndpoint(_inputQueueAddress); _inputQueueSendEndpoint.ConnectSendObserver(_sendObserver); } catch (Exception) { try { using (var tokenSource = new CancellationTokenSource(TestTimeout)) { await _bus.StopAsync(tokenSource.Token); } } finally { _busHandle = null; _bus = null; } throw; } }
public async Task StopAsync(CancellationToken cancellationToken) { await _busControl.StopAsync(); _logger.LogInformation("Payment microservice stopped."); }