Exemple #1
0
        private static void RunPressure(RedisMessageSender redisMessageSender)
        {
            var thread = new Thread(async() =>
            {
                var db = _multiplexer.GetDatabase();
                for (var i = 0; i < 200; i++)
                {
                    var key   = _uniqPrefix + i;
                    var value = i;

                    var redisMessage = new StringRedisMessage(value.ToString());

                    var transaction = db.CreateTransaction();

#pragma warning disable 4014
                    transaction.StringSetAsync(key, value);
#pragma warning restore 4014
                    redisMessageSender.Send(transaction, key, redisMessage);

                    await transaction.ExecuteAsync();

                    Console.WriteLine($"sent {i}");
                }
            })
            {
                IsBackground = true
            };

            thread.Start();
        }
Exemple #2
0
        protected async Task SendMessage(string taskQueue, string messageId, TestMessage testMessage)
        {
            var multiplexer = ConnectionMultiplexer.Connect(ConnectionString);
            var db          = multiplexer.GetDatabase();
            var tr          = db.CreateTransaction();

            var sender = new RedisMessageSender(taskQueue);

            sender.Send(tr, messageId, testMessage);

            await tr.ExecuteAsync();
        }