本文整理汇总了C#中MessageHandler.GetTestResults方法的典型用法代码示例。如果您正苦于以下问题:C# MessageHandler.GetTestResults方法的具体用法?C# MessageHandler.GetTestResults怎么用?C# MessageHandler.GetTestResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageHandler
的用法示例。
在下文中一共展示了MessageHandler.GetTestResults方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestRdyRedistribution
private static List<TestResults> TestRdyRedistribution(
bool rdyRedistributeOnIdle,
int maxInFlight,
TimeSpan rdyRedistributeInterval,
TimeSpan lowRdyIdleTimeout,
TimeSpan handlerSleepTime,
TimeSpan sleepBeforeIdlePublish,
TimeSpan testDuration,
bool startWithInitialMessageOnIdleNsqd,
int numberOfMessagesToSendOnIdleNsqd,
int numberOfMessages
)
{
string topicName = string.Format("test_rdy_redistribution_{0}", DateTime.Now.UnixNano());
try
{
_nsqdHttpClient1.CreateTopic(topicName);
_nsqdHttpClient2.CreateTopic(topicName);
_nsqLookupdHttpClient.CreateTopic(topicName);
Producer p1 = new Producer("127.0.0.1:4150");
if (startWithInitialMessageOnIdleNsqd)
{
p1.Publish(topicName, "initial");
}
Producer p2 = new Producer("127.0.0.1:5150");
for (int i = 0; i < numberOfMessages; i++)
{
p2.Publish(topicName, i.ToString());
}
Consumer c = new Consumer(
topicName,
"test-channel",
new TestConsoleLogger(),
new Config
{
MaxInFlight = maxInFlight,
LowRdyIdleTimeout = lowRdyIdleTimeout,
RDYRedistributeInterval = rdyRedistributeInterval,
RDYRedistributeOnIdle = rdyRedistributeOnIdle
}
);
var messageHandler = new MessageHandler(handlerSleepTime);
c.AddHandler(messageHandler, threads: maxInFlight);
c.ConnectToNsqLookupd("127.0.0.1:4161");
Thread.Sleep(sleepBeforeIdlePublish);
for (int i = 1; i <= numberOfMessagesToSendOnIdleNsqd; i++)
{
p1.Publish(topicName, string.Format("{0} - snuck in!", i));
}
Thread.Sleep(testDuration - sleepBeforeIdlePublish);
p1.Stop();
p2.Stop();
c.Stop();
return messageHandler.GetTestResults();
}
finally
{
_nsqdHttpClient1.DeleteTopic(topicName);
_nsqdHttpClient2.DeleteTopic(topicName);
_nsqLookupdHttpClient.DeleteTopic(topicName);
}
}