forked from MassTransit/MassTransit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50d3e34
commit d38e5b8
Showing
20 changed files
with
472 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Transports/MassTransit.RabbitMqTransport/RabbitMqTransport/BaseEntitySettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace MassTransit.RabbitMqTransport | ||
{ | ||
using System.Collections.Generic; | ||
using Configuration; | ||
|
||
|
||
public abstract class BaseEntitySettings : EntitySettings | ||
{ | ||
readonly RabbitMqExchangeConfigurator _exchangeConfigurator; | ||
|
||
protected BaseEntitySettings(RabbitMqExchangeConfigurator exchangeConfigurator) | ||
{ | ||
_exchangeConfigurator = exchangeConfigurator; | ||
} | ||
|
||
public virtual bool Durable | ||
{ | ||
get => _exchangeConfigurator.Durable; | ||
set => _exchangeConfigurator.Durable = value; | ||
} | ||
|
||
public virtual bool AutoDelete | ||
{ | ||
get => _exchangeConfigurator.AutoDelete; | ||
set => _exchangeConfigurator.AutoDelete = value; | ||
} | ||
|
||
public IDictionary<string, object> ExchangeArguments => _exchangeConfigurator.ExchangeArguments; | ||
|
||
public string ExchangeName | ||
{ | ||
get => _exchangeConfigurator.ExchangeName; | ||
set => _exchangeConfigurator.ExchangeName = value; | ||
} | ||
|
||
public string ExchangeType | ||
{ | ||
get => _exchangeConfigurator.ExchangeType; | ||
set => _exchangeConfigurator.ExchangeType = value; | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/Transports/MassTransit.RabbitMqTransport/RabbitMqTransport/BaseReceiveSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
namespace MassTransit.RabbitMqTransport | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Configuration; | ||
|
||
|
||
public abstract class BaseReceiveSettings : BaseEntitySettings, ReceiveSettings | ||
{ | ||
readonly ExchangeQueueBindingConfigurator _bindingConfigurator; | ||
|
||
protected BaseReceiveSettings(ExchangeQueueBindingConfigurator bindingConfigurator) | ||
: base(bindingConfigurator.ExchangeConfigurator) | ||
{ | ||
_bindingConfigurator = bindingConfigurator; | ||
} | ||
|
||
RabbitMqQueueConfigurator QueueConfigurator => _bindingConfigurator.QueueConfigurator; | ||
RabbitMqExchangeConfigurator ExchangeConfigurator => _bindingConfigurator.ExchangeConfigurator; | ||
|
||
public string QueueName | ||
{ | ||
get => QueueConfigurator.QueueName; | ||
set => QueueConfigurator.QueueName = value; | ||
} | ||
|
||
public bool Exclusive | ||
{ | ||
get => QueueConfigurator.Exclusive; | ||
set => QueueConfigurator.Exclusive = value; | ||
} | ||
|
||
public IDictionary<string, object> QueueArguments => QueueConfigurator.QueueArguments; | ||
|
||
public TimeSpan? QueueExpiration | ||
{ | ||
get => QueueConfigurator.QueueExpiration; | ||
set => QueueConfigurator.QueueExpiration = value; | ||
} | ||
|
||
public string RoutingKey | ||
{ | ||
get => _bindingConfigurator.RoutingKey; | ||
set => _bindingConfigurator.RoutingKey = value; | ||
} | ||
|
||
public IDictionary<string, object> BindingArguments => _bindingConfigurator.BindingArguments; | ||
|
||
public override bool Durable | ||
{ | ||
get => ExchangeConfigurator.Durable && QueueConfigurator.Durable; | ||
set => ExchangeConfigurator.Durable = QueueConfigurator.Durable = value; | ||
} | ||
|
||
public override bool AutoDelete | ||
{ | ||
get => ExchangeConfigurator.AutoDelete && QueueConfigurator.AutoDelete; | ||
set => ExchangeConfigurator.AutoDelete = QueueConfigurator.AutoDelete = value; | ||
} | ||
|
||
public abstract ushort PrefetchCount { get; set; } | ||
|
||
public abstract bool PurgeOnStartup { get; set; } | ||
|
||
public abstract IDictionary<string, object> ConsumeArguments { get; } | ||
|
||
public abstract bool ExclusiveConsumer { get; set; } | ||
public abstract bool BindQueue { get; set; } | ||
public abstract bool NoAck { get; set; } | ||
public abstract string ConsumerTag { get; set; } | ||
|
||
public virtual Uri GetInputAddress(Uri hostAddress) | ||
{ | ||
return _bindingConfigurator.ExchangeConfigurator.GetEndpointAddress(hostAddress); | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...sit.RabbitMqTransport/RabbitMqTransport/Configuration/ExchangeQueueBindingConfigurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
namespace MassTransit.RabbitMqTransport.Configuration | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Topology; | ||
|
||
|
||
public class ExchangeQueueBindingConfigurator | ||
{ | ||
public RabbitMqQueueConfigurator QueueConfigurator { get; } | ||
public RabbitMqExchangeConfigurator ExchangeConfigurator { get; } | ||
|
||
public ExchangeQueueBindingConfigurator(string name, string exchangeType, bool durable, bool autoDelete) | ||
{ | ||
QueueConfigurator = new MyQueueConfigurator(name, durable, autoDelete); | ||
ExchangeConfigurator = new MyExchangeConfigurator(name, exchangeType, durable, autoDelete); | ||
|
||
BindingArguments = new Dictionary<string, object>(); | ||
RoutingKey = ""; | ||
} | ||
public ExchangeQueueBindingConfigurator(string exchangeName, string queueName, string exchangeType, bool durable, bool autoDelete) | ||
{ | ||
QueueConfigurator = new MyQueueConfigurator(queueName, durable, autoDelete); | ||
ExchangeConfigurator = new MyExchangeConfigurator(exchangeName, exchangeType, durable, autoDelete); | ||
|
||
BindingArguments = new Dictionary<string, object>(); | ||
RoutingKey = ""; | ||
} | ||
|
||
public IDictionary<string, object> BindingArguments { get; } | ||
|
||
public void SetBindingArgument(string key, object value) | ||
{ | ||
if (key == null) | ||
throw new ArgumentNullException(nameof(key)); | ||
|
||
if (value == null) | ||
BindingArguments.Remove(key); | ||
else | ||
BindingArguments[key] = value; | ||
} | ||
|
||
public string RoutingKey { get; set; } | ||
|
||
public void AutoDeleteAfter(TimeSpan duration) | ||
{ | ||
QueueConfigurator.AutoDelete = true; | ||
ExchangeConfigurator.AutoDelete = true; | ||
|
||
QueueConfigurator.QueueExpiration = duration; | ||
} | ||
|
||
private class MyQueueConfigurator : RabbitMqQueueConfigurator | ||
{ | ||
public MyQueueConfigurator(string queueName, bool durable, bool autoDelete) | ||
: base(queueName, durable, autoDelete) | ||
{ | ||
} | ||
} | ||
|
||
|
||
private class MyExchangeConfigurator : RabbitMqExchangeConfigurator | ||
{ | ||
public MyExchangeConfigurator(string exchangeName, string exchangeType, bool durable = true, bool autoDelete = false) | ||
: base(exchangeName, exchangeType, durable, autoDelete) | ||
{ | ||
} | ||
|
||
public MyExchangeConfigurator(Exchange source) | ||
: base(source) | ||
{ | ||
} | ||
} | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
...MassTransit.RabbitMqTransport/RabbitMqTransport/Configuration/QueueBindingConfigurator.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.