Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
YarinOmesi committed Sep 2, 2023
1 parent ce7170f commit cad9e16
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public void AutoDeleteAfter(TimeSpan duration)
QueueConfigurator.QueueExpiration = duration;
}

public string QueueName => QueueConfigurator.QueueName;

public IDictionary<string, object> QueueArguments => QueueConfigurator.QueueArguments;

public bool Exclusive
{
get => QueueConfigurator.Exclusive;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
namespace MassTransit.RabbitMqTransport.Configuration
{
using System.Collections.Generic;
using Topology;


/// <summary>
/// Used to bind an exchange to the consuming queue's exchange
/// </summary>
public class ExchangeToQueueBindingConsumeTopologySpecification : BaseExchangeToQueueBindingTopologySpecification,
public class ExchangeToQueueBindingConsumeTopologySpecification : ExchangeQueueBindingConfigurator,
IRabbitMqConsumeTopologySpecification
{
public ExchangeToQueueBindingConsumeTopologySpecification(string exchangeName, string exchangeType, string queueName = null, bool durable = true,
bool autoDelete = false)
: base(exchangeName, exchangeType, queueName, durable, autoDelete)
: base(exchangeName, queueName ?? exchangeName, exchangeType, durable, autoDelete)
{
}

public void Apply(IReceiveEndpointBrokerTopologyBuilder builder) => ApplyTopologyToBuilder(builder);
public IEnumerable<ValidationResult> Validate()
{
yield break;
}

public void Apply(IReceiveEndpointBrokerTopologyBuilder builder)
{
var exchangeHandle = builder.ExchangeDeclare(ExchangeName, ExchangeType, Durable, AutoDelete, ExchangeArguments);

var queueHandle = builder.QueueDeclare(QueueName, Durable, AutoDelete, Exclusive, QueueArguments);

var bindingHandle = builder.QueueBind(exchangeHandle, queueHandle, RoutingKey, BindingArguments);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,28 @@ namespace MassTransit.RabbitMqTransport.Configuration
/// <summary>
/// Used to declare an exchange and queue, and bind them together.
/// </summary>
public class ExchangeToQueueBindingPublishTopologySpecification : BaseExchangeToQueueBindingTopologySpecification,
public class ExchangeToQueueBindingPublishTopologySpecification : ExchangeQueueBindingConfigurator,
IRabbitMqPublishTopologySpecification
{
public ExchangeToQueueBindingPublishTopologySpecification(string exchangeName, string exchangeType, string queueName = null, bool durable = true, bool autoDelete = false)
: base(exchangeName, exchangeType, queueName, durable, autoDelete)
public ExchangeToQueueBindingPublishTopologySpecification(string exchangeName, string exchangeType, string queueName = null, bool durable = true,
bool autoDelete = false)
: base(exchangeName, queueName ?? exchangeName, exchangeType, durable, autoDelete)

{
}

public IEnumerable<ValidationResult> Validate()
{
yield break;
}

public void Apply(IPublishEndpointBrokerTopologyBuilder builder) => ApplyTopologyToBuilder(builder);
public void Apply(IPublishEndpointBrokerTopologyBuilder builder)
{
var exchangeHandle = builder.ExchangeDeclare(ExchangeName, ExchangeType, Durable, AutoDelete, ExchangeArguments);

var queueHandle = builder.QueueDeclare(QueueName, Durable, AutoDelete, Exclusive, QueueArguments);

var bindingHandle = builder.QueueBind(exchangeHandle, queueHandle, RoutingKey, BindingArguments);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,9 @@ public BrokerTopology GetBrokerTopology()
{
var builder = new PublishEndpointBrokerTopologyBuilder();

builder.Exchange = builder.ExchangeDeclare(
ExchangeConfigurator.ExchangeName,
ExchangeConfigurator.ExchangeType,
ExchangeConfigurator.Durable,
ExchangeConfigurator.AutoDelete,
ExchangeConfigurator.ExchangeArguments);

var queue = builder.QueueDeclare(
QueueConfigurator.QueueName,
QueueConfigurator.Durable,
!QueueConfigurator.QueueExpiration.HasValue && QueueConfigurator.AutoDelete,
false,
QueueConfigurator.QueueArguments);
builder.Exchange = builder.ExchangeDeclare(ExchangeName, ExchangeType, Durable, AutoDelete, ExchangeArguments);

var queue = builder.QueueDeclare(QueueName, Durable, !QueueExpiration.HasValue && AutoDelete, false, QueueArguments);

builder.QueueBind(builder.Exchange, queue, RoutingKey, BindingArguments);

Expand Down

0 comments on commit cad9e16

Please sign in to comment.