public async Task InitializeAsync(string passphrase, string salt) { await _serviceLock.WaitAsync().ConfigureAwait(false); try { if (!Initialized) { _hashKey = await ArgonHash .GetHashKeyAsync(passphrase, salt, Constants.EncryptionKeySize) .ConfigureAwait(false); await ChannelPool .InitializeAsync() .ConfigureAwait(false); await AutoPublisher .StartAsync(_hashKey) .ConfigureAwait(false); await FinishSettingUpConsumersAsync().ConfigureAwait(false); Initialized = true; } } finally { _serviceLock.Release(); } }
public async Task AutoPublishAndConsume() { await autoPublisher.StartAsync().ConfigureAwait(false); const ulong count = 10000; var processReceiptsTask = ProcessReceiptsAsync(autoPublisher, count); var publishLettersTask = PublishLettersAsync(autoPublisher, count); var consumeMessagesTask = ConsumeMessagesAsync(consumer, count); while (!publishLettersTask.IsCompleted) { await Task.Delay(1).ConfigureAwait(false); } while (!processReceiptsTask.IsCompleted) { await Task.Delay(1).ConfigureAwait(false); } await autoPublisher.StopAsync().ConfigureAwait(false); while (!consumeMessagesTask.IsCompleted) { await Task.Delay(1).ConfigureAwait(false); } Assert.True(publishLettersTask.IsCompletedSuccessfully); Assert.True(processReceiptsTask.IsCompletedSuccessfully); Assert.True(consumeMessagesTask.IsCompletedSuccessfully); Assert.False(processReceiptsTask.Result); Assert.False(consumeMessagesTask.Result); await topologer.DeleteQueueAsync("TestAutoPublisherConsumerQueue").ConfigureAwait(false); }
public async Task InitializeAsync() { await _serviceLock.WaitAsync().ConfigureAwait(false); try { if (!Initialized) { await ChannelPool .InitializeAsync() .ConfigureAwait(false); await AutoPublisher .StartAsync() .ConfigureAwait(false); await FinishSettingUpConsumersAsync().ConfigureAwait(false); Initialized = true; } } finally { _serviceLock.Release(); } }