当前位置: 首页>>代码示例>>C#>>正文


C# QueueClient.Enqueue方法代码示例

本文整理汇总了C#中QueueClient.Enqueue方法的典型用法代码示例。如果您正苦于以下问题:C# QueueClient.Enqueue方法的具体用法?C# QueueClient.Enqueue怎么用?C# QueueClient.Enqueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QueueClient的用法示例。


在下文中一共展示了QueueClient.Enqueue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestHostUnreachableResponseTime

        public void TestHostUnreachableResponseTime()
        {
            RedisServer.Kill();

            var stopWatch = new Stopwatch();

            try
            {
                using (var client = new QueueClient())
                {
                    var homemadeTask = new TaskMessage
                    {
                        Parameters = "params",
                        Queue = "TestQueue"
                    };

                    stopWatch.Start();
                    client.Enqueue(homemadeTask);
                    stopWatch.Stop();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Elapsed time: {0} ms", stopWatch.ElapsedMilliseconds);
                Console.WriteLine(exception.ToString());
                RedisServer.Start();
                Assert.Pass();
            }
        }
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:29,代码来源:QueueClientTests.cs

示例2: TestCachingCreatesAFile

		public void TestCachingCreatesAFile()
		{
			using (var client = new QueueClient())
			{
				var homemadeTask = new TaskMessage
				{
					Parameters = "params",
					Queue = "TestQueue"
				};

				client.Enqueue(homemadeTask);
				var retrievedTask = client.Reserve("TestQueue");

				Assert.That(File.Exists("redisCache.bin"));

				client.Fail(string.Empty);
				client.RemoveTask(client.AllTasks("TestQueue")[0]);
			}
		}
开发者ID:JohanAlkemade,项目名称:RedisQueue.Net,代码行数:19,代码来源:QueueClientTests.cs

示例3: TestCanEnqueueTaskInRedisAndReadItBack

		public void TestCanEnqueueTaskInRedisAndReadItBack()
		{
			using(var client = new QueueClient())
			{
				var homemadeTask = new TaskMessage
				{
					Parameters = "params", 
					Queue = "TestQueue"
				};

				client.Enqueue(homemadeTask);
				var retrievedTask = client.Reserve("TestQueue");
			
				Assert.AreEqual(retrievedTask.Parameters, homemadeTask.Parameters);
				Assert.AreEqual(retrievedTask.Queue, homemadeTask.Queue);

				client.Fail(string.Empty);
				client.RemoveTask(client.AllTasks("TestQueue")[0]);
			}
		}
开发者ID:JohanAlkemade,项目名称:RedisQueue.Net,代码行数:20,代码来源:QueueClientTests.cs

示例4: TestHostDifferentPort

        public void TestHostDifferentPort()
        {
            var stopWatch = new Stopwatch();

            try
            {
                using (var client = new QueueClient("localhost", 6377, false))
                {
                    var homemadeTask = new TaskMessage
                    {
                        Parameters = "params",
                        Queue = "TestQueue"
                    };

                    stopWatch.Start();
                    client.Enqueue(homemadeTask);
                    stopWatch.Stop();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Elapsed time: {0} ms", stopWatch.ElapsedMilliseconds);
                Console.WriteLine(exception.ToString());
                Assert.Pass();
            }
        }
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:26,代码来源:QueueClientTests.cs

示例5: TestModifyTaskOnCollectionThenAssertModificationDoesNotWork

        public void TestModifyTaskOnCollectionThenAssertModificationDoesNotWork()
        {
            using (var client = new QueueClient())
            {
                // first enqueue a simple task.
                client.Enqueue(new TaskMessage
                {
                    Parameters = "Test Params",
                    Queue = "TestQueue"
                });

                // now modify the task from within the collection.
                client.PendingTasks("TestQueue")[0].Parameters = "Test Params 2";
            }

            // Dispose of the previous client to ensure modifications dont persist in its memory.
            using (var client = new QueueClient())
            {
                // using a new client, read the task again.
                var task = client.PendingTasks("TestQueue")[0];

                Assert.AreEqual(task.Parameters, "Test Params");

                client.RemoveTask(client.AllTasks("TestQueue")[0]);
            }
        }
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:26,代码来源:QueueClientTests.cs

示例6: TestCantReserveMultipleTasksAtOnce

        public void TestCantReserveMultipleTasksAtOnce()
        {
            using (var client = new QueueClient())
            {
                client.Enqueue(new TaskMessage
                {
                    Parameters = "params",
                    Queue = "TestQueue"
                });

                client.Enqueue(new TaskMessage
                {
                    Parameters = "params",
                    Queue = "TestQueue"
                });

                client.Reserve("TestQueue");
                Assert.Throws<TaskAlreadyReservedException>(() => client.Reserve("TestQueue"));

                client.Fail(string.Empty);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
            }
        }
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:24,代码来源:QueueClientTests.cs

示例7: TestCantEnqueueWithoutSettingAQueueInTheTaskMessage

 public void TestCantEnqueueWithoutSettingAQueueInTheTaskMessage()
 {
     using (var client = new QueueClient())
         Assert.Throws<NoQueueSpecifiedException>(
             () => client.Enqueue(new TaskMessage { Parameters = "Test" }));
 }
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:6,代码来源:QueueClientTests.cs

示例8: TestThrowsExceptionOnRedisDeath

        public void TestThrowsExceptionOnRedisDeath()
        {
            var client = new QueueClient();
            RedisServer.Kill();

            Assert.Throws<IOException>(() => client.Enqueue(new TaskMessage
            {
                Parameters = "params",
                Queue = "TestQueue"
            }));

            RedisServer.Start();
        }
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:13,代码来源:QueueClientTests.cs

示例9: TestEnqueueAndDelete100Tasks

        public void TestEnqueueAndDelete100Tasks()
        {
            var client = new QueueClient();
            for (var i = 0; i < 100; i++)
            {
                client.Enqueue(new TaskMessage
                {
                    Parameters = "params",
                    Queue = "TestQueue"
                });
            }

            Assert.AreEqual(client.AllTasks("TestQueue").Count, 100);

            var deletedTasks = 0;
            while (client.AllTasks("TestQueue").Count > 0)
            {
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
                deletedTasks++;
            }

            Assert.AreEqual(deletedTasks, 100);
        }
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:23,代码来源:QueueClientTests.cs

示例10: TestCachingCanPreserveTask

        public void TestCachingCanPreserveTask()
        {
            using (var client = new QueueClient())
            {
                var homemadeTask = new TaskMessage
                {
                    Parameters = "params",
                    Queue = "TestQueue"
                };

                client.Enqueue(homemadeTask);
                var retrievedTask = client.Reserve("TestQueue");
            }

            using (var client = new QueueClient())
            {
                Assert.That(client.CurrentTask != null);
                client.Fail(string.Empty);
                client.RemoveTask(client.AllTasks("TestQueue")[0]);
            }
        }
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:21,代码来源:QueueClientTests.cs

示例11: TestWriteLatencyForDifferentPayloads

        public void TestWriteLatencyForDifferentPayloads()
        {
            var stopWatch = new Stopwatch();

            using (var client = new QueueClient())
            {
                // Small message
                var homemadeTask = new TaskMessage
                {
                    Parameters = RandomString(1024),
                    Queue = "TestQueue"
                };

                stopWatch.Start();
                client.Enqueue(homemadeTask);
                stopWatch.Stop();

                Console.WriteLine("1K Message write latency (no network included): {0} ms", stopWatch.ElapsedMilliseconds);

                // Medium message
                homemadeTask = new TaskMessage
                {
                    Parameters = RandomString(1024 * 10),
                    Queue = "TestQueue"
                };

                stopWatch.Start();
                client.Enqueue(homemadeTask);
                stopWatch.Stop();

                Console.WriteLine("10K Message write latency (no network included): {0} ms", stopWatch.ElapsedMilliseconds);

                // Large message
                homemadeTask = new TaskMessage
                {
                    Parameters = RandomString(1024 * 100),
                    Queue = "TestQueue"
                };

                stopWatch.Start();
                client.Enqueue(homemadeTask);
                stopWatch.Stop();

                Console.WriteLine("100K Message write latency (no network included): {0} ms", stopWatch.ElapsedMilliseconds);
            }
        }
开发者ID:e-travel,项目名称:RedisQueue.Net,代码行数:46,代码来源:QueueClientTests.cs


注:本文中的QueueClient.Enqueue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。