Skip to content

Commit 57a9789

Browse files
EmilianoMussosungam3rmicdenny
authored
GetConsumersAsync method (#146)
* Implemented GetConsumersAsync method, with serialization test Implemented Consumer and QueueName classes * Modified embedded resources inclusion tags * Update Source/EasyNetQ.Management.Client/ManagementClient.cs Accepted suggestion Co-authored-by: Ivan Maximov <sungam3r@yandex.ru> * Extended RabbitMqFixture timeout * update travis badge to point travis.com Co-authored-by: Ivan Maximov <sungam3r@yandex.ru> Co-authored-by: Michael Denny <micdenny@gmail.com>
1 parent 984e095 commit 57a9789

11 files changed

Lines changed: 1020 additions & 898 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![Appveyor build status](https://ci.appveyor.com/api/projects/status/s3a158jwtxgwco90/branch/master?svg=true)](https://ci.appveyor.com/api/projects/status/s3a158jwtxgwco90/branch/master)
2-
[![Travis build Status](https://travis-ci.org/EasyNetQ/EasyNetQ.Management.Client.svg?branch=master)](https://travis-ci.org/EasyNetQ/EasyNetQ.Management.Client)
2+
[![Travis build Status](https://travis-ci.com/EasyNetQ/EasyNetQ.Management.Client.svg?branch=master)](https://travis-ci.com/EasyNetQ/EasyNetQ.Management.Client)
33
----------
44

55
## EasyNetQ.Management.Client

Source/EasyNetQ.Management.Client.IntegrationTests/ManagementClientTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,18 @@ public async Task Should_get_bindings()
918918
Console.Out.WriteLine("binding.Source = {0}", binding.Source);
919919
Console.Out.WriteLine("binding.PropertiesKey = {0}", binding.PropertiesKey);
920920
}
921+
}
922+
923+
[Fact(Skip = "Requires at least a consumer")]
924+
public async Task Should_get_consumers()
925+
{
926+
foreach (var consumer in await managementClient.GetConsumersAsync().ConfigureAwait(false))
927+
{
928+
Console.Out.WriteLine("consumer.ConsumerTag = {0}", consumer.ConsumerTag);
929+
Console.Out.WriteLine("consumer.ChannelDetails.ConnectionName = {0}", consumer.ChannelDetails.ConnectionName);
930+
Console.Out.WriteLine("consumer.ChannelDetails.ConnectionName = {0}", consumer.ChannelDetails.ConnectionName);
931+
Console.Out.WriteLine("consumer.ChannelDetails.Node = {0}", consumer.ChannelDetails.Node);
932+
}
921933
}
922934

923935
[Fact]

Source/EasyNetQ.Management.Client.IntegrationTests/RabbitMqFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class RabbitMqFixtureCollection : ICollectionFixture<RabbitMqFixture>
1717

1818
public class RabbitMqFixture : IAsyncLifetime, IDisposable
1919
{
20-
private static readonly TimeSpan InitializationTimeout = TimeSpan.FromMinutes(2);
20+
private static readonly TimeSpan InitializationTimeout = TimeSpan.FromMinutes(10);
2121

2222
private readonly DockerProxy dockerProxy;
2323
private OSPlatform dockerEngineOsPlatform;

Source/EasyNetQ.Management.Client.Tests/EasyNetQ.Management.Client.Tests.csproj

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<None Remove="Json\Bindings.json" />
10-
<None Remove="Json\Channels.json" />
11-
<None Remove="Json\Connections.json" />
12-
<None Remove="Json\Definitions.json" />
13-
<None Remove="Json\Exchanges.json" />
14-
<None Remove="Json\Federations.json" />
15-
<None Remove="Json\Nodes.json" />
16-
<None Remove="Json\Overview.json" />
17-
<None Remove="Json\Policies_ha.json" />
18-
<None Remove="Json\Queues.json" />
19-
</ItemGroup>
20-
21-
<ItemGroup>
22-
<EmbeddedResource Include="Json\Bindings.json">
23-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
24-
</EmbeddedResource>
25-
<EmbeddedResource Include="Json\Channels.json">
26-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
27-
</EmbeddedResource>
28-
<EmbeddedResource Include="Json\Connections.json">
29-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
30-
</EmbeddedResource>
31-
<EmbeddedResource Include="Json\Definitions.json">
32-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
33-
</EmbeddedResource>
34-
<EmbeddedResource Include="Json\Exchanges.json">
35-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
36-
</EmbeddedResource>
37-
<EmbeddedResource Include="Json\Federations.json">
38-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
39-
</EmbeddedResource>
40-
<EmbeddedResource Include="Json\Nodes.json">
41-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
42-
</EmbeddedResource>
43-
<EmbeddedResource Include="Json\Overview.json">
44-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
45-
</EmbeddedResource>
46-
<EmbeddedResource Include="Json\Policies_ha.json">
47-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
48-
</EmbeddedResource>
49-
<EmbeddedResource Include="Json\Queues.json">
50-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
9+
<EmbeddedResource Include="Json\*.json">
10+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
5111
</EmbeddedResource>
5212
</ItemGroup>
5313

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
[
2+
{
3+
"arguments": {
4+
"x-cancel-on-ha-failover": false,
5+
"x-priority": 0
6+
},
7+
"ack_required": true,
8+
"active": true,
9+
"activity_status": "up",
10+
"channel_details": {
11+
"connection_name": "[::1]:65216 -> [::1]:5672",
12+
"name": "[::1]:65216 -> [::1]:5672 (4)",
13+
"node": "rabbit@LOCALHOST",
14+
"number": 4,
15+
"peer_host": "::1",
16+
"peer_port": 65216,
17+
"user": "guest"
18+
},
19+
"consumer_tag": "60479aa8-c8b8-43d1-baee-e45731b53024",
20+
"exclusive": false,
21+
"prefetch_count": 50,
22+
"queue": {
23+
"name": "Queue01",
24+
"vhost": "/"
25+
}
26+
},
27+
{
28+
"arguments": {
29+
"x-cancel-on-ha-failover": false,
30+
"x-priority": 0
31+
},
32+
"ack_required": true,
33+
"active": true,
34+
"activity_status": "up",
35+
"channel_details": {
36+
"connection_name": "[::1]:65216 -> [::1]:5672",
37+
"name": "[::1]:65216 -> [::1]:5672 (3)",
38+
"node": "rabbit@LOCALHOST",
39+
"number": 3,
40+
"peer_host": "::1",
41+
"peer_port": 65216,
42+
"user": "guest"
43+
},
44+
"consumer_tag": "90479aa8-c8b8-43d1-baee-e45731b53111",
45+
"exclusive": false,
46+
"prefetch_count": 50,
47+
"queue": {
48+
"name": "Queue02",
49+
"vhost": "/"
50+
}
51+
},
52+
{
53+
"arguments": {
54+
"x-cancel-on-ha-failover": false,
55+
"x-priority": 0
56+
},
57+
"ack_required": true,
58+
"active": true,
59+
"activity_status": "up",
60+
"channel_details": {
61+
"connection_name": "[::1]:65216 -> [::1]:5672",
62+
"name": "[::1]:65216 -> [::1]:5672 (1)",
63+
"node": "rabbit@LOCALHOST",
64+
"number": 1,
65+
"peer_host": "::1",
66+
"peer_port": 65216,
67+
"user": "guest"
68+
},
69+
"consumer_tag": "123459aa8-c8b8-43d1-baee-e45731b53024",
70+
"exclusive": false,
71+
"prefetch_count": 50,
72+
"queue": {
73+
"name": "Queue03",
74+
"vhost": "/"
75+
}
76+
}
77+
]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Collections.Generic;
2+
using EasyNetQ.Management.Client.Model;
3+
using FluentAssertions;
4+
using Xunit;
5+
6+
namespace EasyNetQ.Management.Client.Tests.Model
7+
{
8+
public class ConsumerSerializationTests
9+
{
10+
private readonly List<Consumer> consumers;
11+
12+
public ConsumerSerializationTests()
13+
{
14+
consumers = ResourceLoader.LoadObjectFromJson<List<Consumer>>("Consumers.json");
15+
}
16+
17+
[Fact]
18+
public void Should_load_three_consumers()
19+
{
20+
consumers.Count.Should().Be(3);
21+
}
22+
23+
[Fact]
24+
public void Should_have_consumer_properties()
25+
{
26+
var consumer = consumers[0];
27+
28+
consumer.Queue.Name.Should().Be("Queue01");
29+
consumer.ChannelDetails.Node.Should().Be("rabbit@LOCALHOST");
30+
}
31+
}
32+
}
33+
34+
// ReSharper restore InconsistentNaming

Source/EasyNetQ.Management.Client/IManagementClient.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ Task<Channel> GetChannelAsync(
147147
/// <returns></returns>
148148
Task<IReadOnlyList<TopicPermission>> GetTopicPermissionsAsync(CancellationToken cancellationToken = default);
149149

150+
/// <summary>
151+
/// A list of all consumers.
152+
/// </summary>
153+
/// <param name="cancellationToken"></param>
154+
/// <returns></returns>
155+
Task<IReadOnlyList<Consumer>> GetConsumersAsync(CancellationToken cancellationToken = default);
156+
150157
/// <summary>
151158
/// Closes the given connection
152159
/// </summary>

0 commit comments

Comments
 (0)