本文整理汇总了C#中Admin.PurgeQueue方法的典型用法代码示例。如果您正苦于以下问题:C# Admin.PurgeQueue方法的具体用法?C# Admin.PurgeQueue怎么用?C# Admin.PurgeQueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Admin
的用法示例。
在下文中一共展示了Admin.PurgeQueue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSetUp
protected override void OnSetUp()
{
admin = new Admin("tcp://localhost:7222", "admin", "");
Destination destination = null;
try
{
destination = (Destination) lookupContext.Lookup(queueName);
if (destination != null) admin.DestroyQueue(queueName);
} catch (NameNotFoundException)
{}
admin.CreateQueue(new QueueInfo(queueName));
admin.BindQueue(queueName, queueName);
admin.PurgeQueue(queueName);
}
示例2: SendAndAsyncReceive
public void SendAndAsyncReceive()
{
SimpleMessageListenerContainer container =
(SimpleMessageListenerContainer) applicationContext["SimpleMessageListenerContainer"];
SimpleMessageListener listener = applicationContext["SimpleMessageListener"] as SimpleMessageListener;
Assert.IsNotNull(container);
Assert.IsNotNull(listener);
Admin admin = new Admin("tcp://localhost:7222", "admin", null);
admin.PurgeQueue("test.queue");
EmsTemplate emsTemplate = (EmsTemplate) applicationContext["MessageTemplate"] as EmsTemplate;
Assert.IsNotNull(emsTemplate);
Assert.AreEqual(0, listener.MessageCount);
emsTemplate.ConvertAndSend("Hello World 1");
int waitInMillis = 2000;
Thread.Sleep(waitInMillis);
Assert.AreEqual(1,listener.MessageCount);
container.Stop();
Console.WriteLine("container stopped.");
emsTemplate.ConvertAndSend("Hello World 2");
Thread.Sleep(waitInMillis);
Assert.AreEqual(1, listener.MessageCount);
container.Start();
Console.WriteLine("container started.");
Thread.Sleep(waitInMillis);
Assert.AreEqual(2, listener.MessageCount);
container.Shutdown();
Thread.Sleep(waitInMillis);
}