本文整理匯總了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);
}