public async Task DeclareAsync() { bool exists = await _bunny.ExchangeExistsAsync(Name); if (exists) { return; } IModel channel = null; try { channel = _bunny.Channel(newOne: true); await Task.Run(() => { channel.ExchangeDeclare(Name, ExchangeType, Durable, AutoDelete, _args); }); } catch (System.Exception exc) { throw DeclarationException.DeclareFailed(exc, "exchange-declare failed!"); } finally { channel.Close(); } }
public static Task <bool> ExchangeExistsAsync(this IDeclare declare, string exchangeName) { IBunny bunny = CheckGetBunny(declare, exchangeName, "exchange"); return(bunny.ExchangeExistsAsync(exchangeName)); }