Exemple #1
0
        private static async Task PublishLettersAsync(Publisher apub, string queueName, ulong count)
        {
            var sw = Stopwatch.StartNew();

            for (ulong i = 0; i < count; i++)
            {
                var letter = RandomData.CreateSimpleRandomLetter(queueName, MessageSize);
                letter.Envelope.RoutingOptions.DeliveryMode = 1;
                letter.LetterId = i;

                await apub.QueueLetterAsync(letter).ConfigureAwait(false);

                if (letter.LetterId % 10_000 == 0)
                {
                    await Console
                    .Out
                    .WriteLineAsync($"- QueueName ({queueName}) is publishing letter {letter.LetterId}")
                    .ConfigureAwait(false);
                }
            }
            sw.Stop();

            await Console
            .Out
            .WriteLineAsync($"- Finished queueing all letters in {sw.ElapsedMilliseconds / 60_000.0} minutes.")
            .ConfigureAwait(false);
        }
        public async Task CreateAutoPublisherByConfigQueueAndConcurrentPublish()
        {
            var pub = new Publisher(
                _fixture.Options,
                _fixture.SerializationProvider,
                _fixture.EncryptionProvider,
                _fixture.CompressionProvider);

            await pub.StartAutoPublishAsync().ConfigureAwait(false);

            var         finished = false;
            const ulong count    = 10000;

            await Task.Run(async() =>
            {
                for (ulong i = 0; i < count; i++)
                {
                    var letter      = RandomData.CreateSimpleRandomLetter("AutoPublisherTestQueue");
                    letter.LetterId = i;

                    await pub.QueueLetterAsync(letter).ConfigureAwait(false);
                }

                finished = true;
            }).ConfigureAwait(false);

            while (!finished)
            {
                await Task.Delay(1).ConfigureAwait(false);
            }

            await pub.StopAutoPublishAsync().ConfigureAwait(false);
        }
Exemple #3
0
        public async Task CreateAutoPublisherByConfigQueueAndConcurrentPublish()
        {
            var config = new Config();

            config.FactorySettings.Uri = new Uri("amqp://*****:*****@localhost:5672/");

            var pub = new Publisher(config, new byte[] { });
            await pub.StartAutoPublishAsync().ConfigureAwait(false);

            var         finished = false;
            const ulong count    = 10000;

            await Task.Run(async() =>
            {
                for (ulong i = 0; i < count; i++)
                {
                    var letter      = RandomData.CreateSimpleRandomLetter("AutoPublisherTestQueue");
                    letter.LetterId = i;

                    await pub.QueueLetterAsync(letter).ConfigureAwait(false);
                }

                finished = true;
            }).ConfigureAwait(false);

            while (!finished)
            {
                await Task.Delay(1).ConfigureAwait(false);
            }

            await pub.StopAutoPublishAsync().ConfigureAwait(false);
        }
Exemple #4
0
        public async Task CreateAutoPublisherAndPublish()
        {
            var pub = new Publisher(channelPool, new byte[] { });

            var letter = RandomData.CreateSimpleRandomLetter("AutoPublisherTestQueue");
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await pub.QueueLetterAsync(letter));
        }
        public async Task CreateAutoPublisherAndPublish()
        {
            var pub = new Publisher(
                _fixture.ChannelPool,
                _fixture.SerializationProvider,
                _fixture.EncryptionProvider,
                _fixture.CompressionProvider);

            var letter = RandomData.CreateSimpleRandomLetter("AutoPublisherTestQueue");
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await pub.QueueLetterAsync(letter));
        }
Exemple #6
0
        public async Task CreateAutoPublisherByConfigAndPublish()
        {
            var config = new Config();

            config.FactorySettings.Uri = new Uri("amqp://*****:*****@localhost:5672/");

            var pub = new Publisher(config, new byte[] { });
            await pub.StartAutoPublishAsync().ConfigureAwait(false);

            var letter = RandomData.CreateSimpleRandomLetter("AutoPublisherTestQueue");
            await pub.QueueLetterAsync(letter).ConfigureAwait(false);
        }
        public async Task CreateAutoPublisherByConfigAndPublish()
        {
            var pub = new Publisher(
                _fixture.Options,
                _fixture.SerializationProvider,
                _fixture.EncryptionProvider,
                _fixture.CompressionProvider);

            await pub.StartAutoPublishAsync().ConfigureAwait(false);

            var letter = RandomData.CreateSimpleRandomLetter("AutoPublisherTestQueue");
            await pub.QueueLetterAsync(letter).ConfigureAwait(false);
        }
        public async Task PublishWithoutInitializeToQueueAsync()
        {
            var config = new Config();

            config.FactorySettings.Uri = new Uri("amqp://*****:*****@localhost:5672/");

            var pub    = new Publisher(config, new byte[] { });
            var letter = RandomData.CreateSimpleRandomLetter("TestQueue", 2000);

            await Assert
            .ThrowsAsync <InvalidOperationException>(() => pub.PublishAsync(letter, false))
            .ConfigureAwait(false);
        }
Exemple #9
0
        private async Task PublishLettersAsync(Publisher pub, ulong count)
        {
            var sw = Stopwatch.StartNew();

            for (ulong i = 0; i < count; i++)
            {
                var letter = RandomData.CreateSimpleRandomLetter("AutoPublisherTestQueue");
                letter.LetterId = i;

                await pub.QueueLetterAsync(letter).ConfigureAwait(false);
            }
            sw.Stop();

            output.WriteLine($"Finished queueing all letters in {sw.ElapsedMilliseconds} ms.");
        }
        public async Task PublishAsync()
        {
            var options = new Options();

            options.FactoryOptions.Uri = new Uri("amqp://*****:*****@localhost:5672/");

            var pub = new Publisher(options, new byte[] { });
            await pub
            .StartAutoPublishAsync()
            .ConfigureAwait(false);

            var letter = RandomData.CreateSimpleRandomLetter("TestQueue", 2000);
            await pub
            .PublishAsync(letter, false)
            .ConfigureAwait(false);
        }
Exemple #11
0
        public async Task PublishWithoutInitializeToQueueAsync()
        {
            var options = new Options();

            options.FactoryOptions.Uri = new Uri("amqp://*****:*****@localhost:5672/");

            var pub = new Publisher(
                _fixture.ChannelPool,
                _fixture.SerializationProvider,
                _fixture.EncryptionProvider,
                _fixture.CompressionProvider);

            var letter = RandomData.CreateSimpleRandomLetter("TestQueue", 2000);

            await Assert
            .ThrowsAsync <InvalidOperationException>(() => pub.PublishAsync(letter, false))
            .ConfigureAwait(false);
        }
Exemple #12
0
        public async Task PublishAsync()
        {
            var options = new Options();

            options.FactoryOptions.Uri = new Uri("amqp://*****:*****@localhost:5672/");

            var pub = new Publisher(
                _fixture.ChannelPool,
                _fixture.SerializationProvider,
                _fixture.EncryptionProvider,
                _fixture.CompressionProvider);

            await pub
            .StartAutoPublishAsync()
            .ConfigureAwait(false);

            var letter = RandomData.CreateSimpleRandomLetter("TestQueue", 2000);
            await pub
            .PublishAsync(letter, false)
            .ConfigureAwait(false);
        }