Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rmq API v4 support #90

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<tags>rabbitmq chinchilla</tags>
<dependencies>
<dependency id="RabbitMQ.Client" version="3.6.0" />
<dependency id="RabbitMQ.Client" version="4.1.1" />
</dependencies>
</metadata>
</package>
4 changes: 2 additions & 2 deletions src/Chinchilla.Integration/Chinchilla.Integration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<HintPath>..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="RabbitMQ.Client, Version=3.6.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
<HintPath>..\packages\RabbitMQ.Client.3.6.0\lib\net45\RabbitMQ.Client.dll</HintPath>
<Reference Include="RabbitMQ.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
<HintPath>..\packages\RabbitMQ.Client.4.1.1\lib\net451\RabbitMQ.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion src/Chinchilla.Integration/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.18" targetFramework="net45" />
<package id="NUnit" version="3.5.0" targetFramework="net452" />
<package id="RabbitMQ.Client" version="3.6.0" targetFramework="net452" />
<package id="RabbitMQ.Client" version="4.1.1" targetFramework="net452" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
<HintPath>..\packages\Moq.4.5.29\lib\net45\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="RabbitMQ.Client, Version=3.6.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
<HintPath>..\packages\RabbitMQ.Client.3.6.0\lib\net45\RabbitMQ.Client.dll</HintPath>
<Reference Include="RabbitMQ.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
<HintPath>..\packages\RabbitMQ.Client.4.1.1\lib\net451\RabbitMQ.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion src/Chinchilla.Specifications/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<package id="Machine.Specifications" version="0.11.0" targetFramework="net452" />
<package id="Machine.Specifications.Should" version="0.11.0" targetFramework="net452" />
<package id="Moq" version="4.5.29" targetFramework="net452" />
<package id="RabbitMQ.Client" version="3.6.0" targetFramework="net452" />
<package id="RabbitMQ.Client" version="4.1.1" targetFramework="net452" />
</packages>
4 changes: 2 additions & 2 deletions src/Chinchilla/Chinchilla.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="RabbitMQ.Client, Version=3.6.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
<HintPath>..\packages\RabbitMQ.Client.3.6.0\lib\net45\RabbitMQ.Client.dll</HintPath>
<Reference Include="RabbitMQ.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
<HintPath>..\packages\RabbitMQ.Client.4.1.1\lib\net451\RabbitMQ.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
55 changes: 24 additions & 31 deletions src/Chinchilla/Topologies/Model/TopologyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,30 @@ public void Visit(IQueue queue)
{
VisitOnce(queue, () =>
{
if (queue.HasName)
{
var args = new Dictionary<string, object>();

if (queue.QueueAutoExpire.HasValue)
{
args.Add("x-expires", queue.QueueAutoExpire.Value.TotalMilliseconds);
}
var args = new Dictionary<string, object>();

if (!string.IsNullOrEmpty(queue.DeadLetterExchange))
{
args.Add("x-dead-letter-exchange", queue.DeadLetterExchange);
}

if (queue.MessageTimeToLive.HasValue)
{
args.Add("x-message-ttl", (int)queue.MessageTimeToLive.Value.TotalMilliseconds);
}
if (queue.QueueAutoExpire.HasValue)
{
args.Add("x-expires", queue.QueueAutoExpire.Value.TotalMilliseconds);
}

model.Execute(m =>
m.QueueDeclare(
queue.Name,
queue.Durability == Durability.Durable, // durable
queue.IsExclusive, // exclusive
queue.IsAutoDelete, // auto-delete
args));
if (!string.IsNullOrEmpty(queue.DeadLetterExchange))
{
args.Add("x-dead-letter-exchange", queue.DeadLetterExchange);
}
else

if (queue.MessageTimeToLive.HasValue)
{
var declared = model.Execute(m => m.QueueDeclare());
queue.Name = declared.QueueName;
args.Add("x-message-ttl", (int)queue.MessageTimeToLive.Value.TotalMilliseconds);
}

model.Execute(m =>
m.QueueDeclare(
queue.HasName ? queue.Name : "",
queue.Durability == Durability.Durable, // durable
queue.IsExclusive, // exclusive
queue.IsAutoDelete, // auto-delete
args));
});
}

Expand Down Expand Up @@ -94,7 +86,8 @@ public void Visit(IBinding binding)
{
model.Execute(m =>
{
Action<string, string, string> bindFunction;
Action<string, string, string, IDictionary<string, object>> bindFunction;

if (binding.Bindable is IQueue)
{
bindFunction = m.QueueBind;
Expand All @@ -103,19 +96,19 @@ public void Visit(IBinding binding)
{
// Reverse from/to for binding exchanges, because the parameters of ExchangeBind
// don't match QueueBind
bindFunction = (from, to, keys) => m.ExchangeBind(to, from, keys);
bindFunction = (from, to, keys, args) => m.ExchangeBind(to, from, keys, args);
}

if (binding.RoutingKeys.Any())
{
foreach (var key in binding.RoutingKeys)
{
bindFunction(binding.Bindable.Name, binding.Exchange.Name, key);
bindFunction(binding.Bindable.Name, binding.Exchange.Name, key, null);
}
}
else
{
bindFunction(binding.Bindable.Name, binding.Exchange.Name, "#");
bindFunction(binding.Bindable.Name, binding.Exchange.Name, "#", null);
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/Chinchilla/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="RabbitMQ.Client" version="3.6.0" targetFramework="net452" />
<package id="RabbitMQ.Client" version="4.1.1" targetFramework="net452" />
<package id="SimpleJson" version="0.38.0" targetFramework="net45" />
</packages>