using RabbitMQ.Client;
using System;
public partial class Queue
{
public static void Purge(string hostname, int port, string queuename, string username, string password)
{
try
{
// RabbitMQ server connection parameters
ConnectionFactory factory = new ConnectionFactory
{
HostName = hostname,
Port = port,
UserName = username,
Password = password,
VirtualHost = "/",
ContinuationTimeout = new TimeSpan(1, 0, 0, 0)
};
// Create a connection to the RabbitMQ server
IConnection connection = factory.CreateConnection();
// Create a channel
IModel channel = connection.CreateModel();
channel.QueuePurge(queuename);
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
}
}