public async ValueTask StartAsync(CancellationToken cancellationToken) { if (_producer != null) { throw new InvalidOperationException($"Producer with type {typeof(T).FullName} has already been initialized."); } _producer = await _producerFactory(cancellationToken); }
public async ValueTask StopAsync() { try { await DisposeAsync().ConfigureAwait(false); } catch (Exception exception) { _logger.LogError(exception, "Exception occured during producer stopping."); } finally { _producer = null; } }
protected override async Task RecoverUnderlyingProducer(IConnection connection, CancellationToken cancellationToken) { _producer = await connection.CreateAnonymousProducerAsync(_configuration, cancellationToken).ConfigureAwait(false); }
public TestProducer(IAnonymousProducer producer) => _producer = producer;
public MessageProducer(IAnonymousProducer producer) { _producer = producer; }
public static Task SendAsync(this IAnonymousProducer producer, string address, Message message, Transaction transaction, CancellationToken cancellationToken = default) { return(producer.SendAsync(address, null, message, transaction, cancellationToken)); }
public static Task SendAsync(this IAnonymousProducer producer, string address, RoutingType routingType, Message message, CancellationToken cancellationToken = default) { return(producer.SendAsync(address, routingType, message, null, cancellationToken)); }