Permalink
Browse files

Merge pull request #35 from gediminasgu/master

Autodelete for exchanges
  • Loading branch information...
2 parents 2f9da3c + b3f9c9a commit 91a21c650857ee34ca6af80c859d72998f5eaeac @mikehadlow committed Aug 23, 2012
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -9,6 +10,8 @@ public class Exchange : IExchange
protected readonly IList<IBinding> bindings = new List<IBinding>();
public string Name { get; private set; }
public string ExchangeType { get; private set; }
+ public bool AutoDelete { get; private set; }
+ public IDictionary Arguments { get; private set; }
public static IExchange DeclareDirect(string exchangeName)
{
@@ -19,6 +22,15 @@ public static IExchange DeclareDirect(string exchangeName)
return new Exchange(exchangeName, Topology.ExchangeType.Direct);
}
+ public static IExchange DeclareDirect(string exchangeName, bool autoDelete, IDictionary arguments)
+ {
+ if (string.IsNullOrEmpty(exchangeName))
+ {
+ throw new ArgumentException("name is null or empty");
+ }
+ return new Exchange(exchangeName, Topology.ExchangeType.Direct, autoDelete, arguments);
+ }
+
public static IExchange DeclareTopic(string exchangeName)
{
if (string.IsNullOrEmpty(exchangeName))
@@ -28,6 +40,15 @@ public static IExchange DeclareTopic(string exchangeName)
return new Exchange(exchangeName, Topology.ExchangeType.Topic);
}
+ public static IExchange DeclareTopic(string exchangeName, bool autoDelete, IDictionary arguments)
+ {
+ if (string.IsNullOrEmpty(exchangeName))
+ {
+ throw new ArgumentException("name is null or empty");
+ }
+ return new Exchange(exchangeName, Topology.ExchangeType.Topic, autoDelete, arguments);
+ }
+
public static IExchange DeclareFanout(string exchangeName)
{
if (string.IsNullOrEmpty(exchangeName))
@@ -37,6 +58,15 @@ public static IExchange DeclareFanout(string exchangeName)
return new Exchange(exchangeName, Topology.ExchangeType.Fanout);
}
+ public static IExchange DeclareFanout(string exchangeName, bool autoDelete, IDictionary arguments)
+ {
+ if (string.IsNullOrEmpty(exchangeName))
+ {
+ throw new ArgumentException("name is null or empty");
+ }
+ return new Exchange(exchangeName, Topology.ExchangeType.Fanout, autoDelete, arguments);
+ }
+
public static IExchange GetDefault()
{
return new DefaultExchange();
@@ -53,6 +83,19 @@ protected Exchange(string name, string exchangeType)
ExchangeType = exchangeType;
}
+ protected Exchange(string name, string exchangeType, bool autoDelete, IDictionary arguments)
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
+
+ Name = name;
+ ExchangeType = exchangeType;
+ AutoDelete = autoDelete;
+ Arguments = arguments;
+ }
+
public virtual void Visit(ITopologyVisitor visitor)
{
if (visitor == null)
@@ -61,7 +104,7 @@ public virtual void Visit(ITopologyVisitor visitor)
}
if (Name != string.Empty)
{
- visitor.CreateExchange(Name, ExchangeType);
+ visitor.CreateExchange(Name, ExchangeType, AutoDelete, Arguments);
foreach (var binding in bindings)
{
binding.Visit(visitor);
@@ -1,10 +1,11 @@
+using System.Collections;
using System.Collections.Generic;
namespace EasyNetQ.Topology
{
public interface ITopologyVisitor
{
- void CreateExchange(string exchangeName, string exchangeType);
+ void CreateExchange(string exchangeName, string exchangeType, bool autoDelete, IDictionary arguments);
void CreateQueue(string queueName, bool durable, bool exclusive, bool autoDelete, IDictionary<string, object> arguments);
string CreateQueue();
void CreateBinding(IBindable bindable, IExchange exchange, string[] routingKeys);
@@ -20,14 +20,14 @@ public TopologyBuilder(IModel model)
this.model = model;
}
- public void CreateExchange(string exchangeName, string exchangeType)
+ public void CreateExchange(string exchangeName, string exchangeType, bool autoDelete, IDictionary arguments)
{
if(exchangeName == null)
{
throw new ArgumentNullException("exchangeName");
}
- model.ExchangeDeclare(exchangeName, exchangeType, true);
+ model.ExchangeDeclare(exchangeName, exchangeType, true, autoDelete, arguments);
}
public void CreateQueue(string queueName, bool durable, bool exclusive, bool autoDelete, IDictionary<string, object> arguments)

0 comments on commit 91a21c6

Please sign in to comment.