Skip to content

Commit 7669de5

Browse files
Merge branch 'master' into eliminate.command
2 parents f1463a7 + 849b9b8 commit 7669de5

17 files changed

+194
-183
lines changed

RUNNING_TESTS.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,16 @@ Two options to accomplish this are covered below.
4242

4343
### Option One: Using a RabbitMQ Release
4444

45-
It is possible to install and run a node using any [binary build](https://www.rabbitmq.com/download.html) suitable
46-
for the platform. Its [CLI tools]() then must be added to `PATH` so that `rabbitmqctl` (`rabbitmqctl.bat` on Windows)
47-
can be invoked directly without using an absolute file path.
45+
It is possible to install and run a node using any [binary build](https://www.rabbitmq.com/download.html)
46+
suitable for the platform. Its [CLI tools]() then must be added to `PATH` so that `rabbitmqctl` can be
47+
invoked directly without using an absolute file path. Note that this method does *not* work on Windows.
4848

49+
On Windows, you must run unit tests as follows (replace `X.Y.Z` with your RabbitMQ version):
50+
51+
```
52+
set RABBITMQ_RABBITMQCTL_PATH="C:\Program Files\RabbitMQ Server\rabbitmq_server-X.Y.Z\sbin\rabbitmqctl.bat"
53+
.\run-test.bat
54+
```
4955

5056
### Option Two: Using RabbitMQ Umbrella Repository
5157

projects/Apigen/apigen/Apigen.cs

Lines changed: 81 additions & 70 deletions
Large diffs are not rendered by default.

projects/RabbitMQ.Client/client/api/AmqpTimestamp.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
// Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
3939
//---------------------------------------------------------------------------
4040

41+
using System;
42+
4143
namespace RabbitMQ.Client
4244
{
4345
// time representations in mainstream languages: the horror, the horror
@@ -58,7 +60,7 @@ namespace RabbitMQ.Client
5860
/// timestamps are signed or unsigned.
5961
/// </para>
6062
/// </remarks>
61-
public struct AmqpTimestamp
63+
public struct AmqpTimestamp : IEquatable<AmqpTimestamp>
6264
{
6365
/// <summary>
6466
/// Construct an <see cref="AmqpTimestamp"/>.
@@ -74,6 +76,16 @@ public AmqpTimestamp(long unixTime) : this()
7476
/// </summary>
7577
public long UnixTime { get; private set; }
7678

79+
public bool Equals(AmqpTimestamp other) => UnixTime == other.UnixTime;
80+
81+
public override bool Equals(object obj) => obj is AmqpTimestamp other && Equals(other);
82+
83+
public override int GetHashCode() => UnixTime.GetHashCode();
84+
85+
public static bool operator ==(AmqpTimestamp left, AmqpTimestamp right) => left.Equals(right);
86+
87+
public static bool operator !=(AmqpTimestamp left, AmqpTimestamp right) => !left.Equals(right);
88+
7789
/// <summary>
7890
/// Provides a debugger-friendly display.
7991
/// </summary>

projects/RabbitMQ.Client/client/api/IBasicPublishBatch.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ namespace RabbitMQ.Client
4444
{
4545
public interface IBasicPublishBatch
4646
{
47-
[Obsolete("Use Add(string exchange, string routingKey, bool mandatory, IBasicProperties properties, ReadOnlyMemory<byte> body) instead. Will be replaced in version 7.0", false)]
48-
void Add(string exchange, string routingKey, bool mandatory, IBasicProperties properties, byte[] body);
47+
void Add(string exchange, string routingKey, bool mandatory, IBasicProperties properties, ReadOnlyMemory<byte> body);
4948
void Publish();
5049
}
5150
}

projects/RabbitMQ.Client/client/api/ITcpClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Net;
23
using System.Net.Sockets;
34
using System.Threading.Tasks;
45

@@ -17,6 +18,7 @@ public interface ITcpClient : IDisposable
1718
Socket Client { get; }
1819

1920
Task ConnectAsync(string host, int port);
21+
Task ConnectAsync(IPAddress host, int port);
2022

2123
NetworkStream GetStream();
2224

projects/RabbitMQ.Client/client/impl/AsyncConsumerWorkService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public AsyncConsumerWorkService(int concurrency) : base(concurrency)
1616
_startNewWorkPoolFunc = model => StartNewWorkPool(model);
1717
}
1818

19-
public void Schedule<TWork>(ModelBase model, TWork work) where TWork : Work
19+
public void Schedule<TWork>(IModel model, TWork work) where TWork : Work
2020
{
2121
/*
2222
* rabbitmq/rabbitmq-dotnet-client#841
@@ -29,7 +29,7 @@ public void Schedule<TWork>(ModelBase model, TWork work) where TWork : Work
2929

3030
private WorkPool StartNewWorkPool(IModel model)
3131
{
32-
var newWorkPool = new WorkPool(model as ModelBase, _concurrency);
32+
var newWorkPool = new WorkPool(model, _concurrency);
3333
newWorkPool.Start();
3434
return newWorkPool;
3535
}
@@ -47,13 +47,13 @@ public Task Stop(IModel model)
4747
class WorkPool
4848
{
4949
readonly Channel<Work> _channel;
50-
readonly ModelBase _model;
50+
readonly IModel _model;
5151
private Task _worker;
5252
private readonly int _concurrency;
5353
private SemaphoreSlim _limiter;
5454
private CancellationTokenSource _tokenSource;
5555

56-
public WorkPool(ModelBase model, int concurrency)
56+
public WorkPool(IModel model, int concurrency)
5757
{
5858
_concurrency = concurrency;
5959
_model = model;
@@ -125,7 +125,7 @@ async Task LoopWithConcurrency(CancellationToken cancellationToken)
125125
}
126126
}
127127

128-
static async Task HandleConcurrent(Work work, ModelBase model, SemaphoreSlim limiter)
128+
static async Task HandleConcurrent(Work work, IModel model, SemaphoreSlim limiter)
129129
{
130130
try
131131
{

projects/RabbitMQ.Client/client/impl/BasicCancel.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,25 @@ public BasicCancel(IBasicConsumer consumer, string consumerTag) : base(consumer)
1515
_consumerTag = consumerTag;
1616
}
1717

18-
protected override async Task Execute(ModelBase model, IAsyncBasicConsumer consumer)
18+
protected override async Task Execute(IModel model, IAsyncBasicConsumer consumer)
1919
{
2020
try
2121
{
2222
await consumer.HandleBasicCancel(_consumerTag).ConfigureAwait(false);
2323
}
2424
catch (Exception e)
2525
{
26+
if (!(model is ModelBase modelBase))
27+
{
28+
return;
29+
}
30+
2631
var details = new Dictionary<string, object>
2732
{
2833
{"consumer", consumer},
2934
{"context", "HandleBasicCancel"}
3035
};
31-
model.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
36+
modelBase.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
3237
}
3338
}
3439
}

projects/RabbitMQ.Client/client/impl/BasicCancelOk.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,25 @@ public BasicCancelOk(IBasicConsumer consumer, string consumerTag) : base(consume
1515
_consumerTag = consumerTag;
1616
}
1717

18-
protected override async Task Execute(ModelBase model, IAsyncBasicConsumer consumer)
18+
protected override async Task Execute(IModel model, IAsyncBasicConsumer consumer)
1919
{
2020
try
2121
{
2222
await consumer.HandleBasicCancelOk(_consumerTag).ConfigureAwait(false);
2323
}
2424
catch (Exception e)
2525
{
26+
if (!(model is ModelBase modelBase))
27+
{
28+
return;
29+
}
30+
2631
var details = new Dictionary<string, object>()
2732
{
2833
{"consumer", consumer},
2934
{"context", "HandleBasicCancelOk"}
3035
};
31-
model.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
36+
modelBase.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
3237
}
3338
}
3439
}

projects/RabbitMQ.Client/client/impl/BasicConsumeOk.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,25 @@ public BasicConsumeOk(IBasicConsumer consumer, string consumerTag) : base(consum
1515
_consumerTag = consumerTag;
1616
}
1717

18-
protected override async Task Execute(ModelBase model, IAsyncBasicConsumer consumer)
18+
protected override async Task Execute(IModel model, IAsyncBasicConsumer consumer)
1919
{
2020
try
2121
{
2222
await consumer.HandleBasicConsumeOk(_consumerTag).ConfigureAwait(false);
2323
}
2424
catch (Exception e)
2525
{
26+
if (!(model is ModelBase modelBase))
27+
{
28+
return;
29+
}
30+
2631
var details = new Dictionary<string, object>()
2732
{
2833
{"consumer", consumer},
2934
{"context", "HandleBasicConsumeOk"}
3035
};
31-
model.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
36+
modelBase.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
3237
}
3338
}
3439
}

projects/RabbitMQ.Client/client/impl/BasicDeliver.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ sealed class BasicDeliver : Work
1818
readonly IBasicProperties _basicProperties;
1919
readonly ReadOnlyMemory<byte> _body;
2020

21-
public BasicDeliver(IBasicConsumer consumer,
22-
string consumerTag,
23-
ulong deliveryTag,
24-
bool redelivered,
25-
string exchange,
26-
string routingKey,
21+
public BasicDeliver(IBasicConsumer consumer,
22+
string consumerTag,
23+
ulong deliveryTag,
24+
bool redelivered,
25+
string exchange,
26+
string routingKey,
2727
IBasicProperties basicProperties,
2828
ReadOnlyMemory<byte> body) : base(consumer)
2929
{
@@ -36,7 +36,7 @@ public BasicDeliver(IBasicConsumer consumer,
3636
_body = body;
3737
}
3838

39-
protected override async Task Execute(ModelBase model, IAsyncBasicConsumer consumer)
39+
protected override async Task Execute(IModel model, IAsyncBasicConsumer consumer)
4040
{
4141
try
4242
{
@@ -50,12 +50,17 @@ await consumer.HandleBasicDeliver(_consumerTag,
5050
}
5151
catch (Exception e)
5252
{
53+
if (!(model is ModelBase modelBase))
54+
{
55+
return;
56+
}
57+
5358
var details = new Dictionary<string, object>()
5459
{
5560
{"consumer", consumer},
5661
{"context", "HandleBasicDeliver"}
5762
};
58-
model.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
63+
modelBase.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
5964
}
6065
finally
6166
{

projects/RabbitMQ.Client/client/impl/BasicPublishBatch.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ internal BasicPublishBatch (ModelBase model, int sizeHint)
6262
_commands = new List<OutgoingCommand>(sizeHint);
6363
}
6464

65-
public void Add(string exchange, string routingKey, bool mandatory, IBasicProperties basicProperties, byte[] body)
66-
{
67-
ReadOnlyMemory<byte> bodyAsMemory = body;
68-
Add(exchange, routingKey, mandatory, basicProperties, bodyAsMemory);
69-
}
70-
7165
public void Add(string exchange, string routingKey, bool mandatory, IBasicProperties basicProperties, ReadOnlyMemory<byte> body)
7266
{
7367
var method = new BasicPublish

projects/RabbitMQ.Client/client/impl/BasicPublishBatchExtensions.cs

Lines changed: 0 additions & 61 deletions
This file was deleted.

projects/RabbitMQ.Client/client/impl/ModelShutdown.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,25 @@ public ModelShutdown(IBasicConsumer consumer, ShutdownEventArgs reason) : base(c
1515
_reason = reason;
1616
}
1717

18-
protected override async Task Execute(ModelBase model, IAsyncBasicConsumer consumer)
18+
protected override async Task Execute(IModel model, IAsyncBasicConsumer consumer)
1919
{
2020
try
2121
{
2222
await consumer.HandleModelShutdown(model, _reason).ConfigureAwait(false);
2323
}
2424
catch (Exception e)
2525
{
26+
if (!(model is ModelBase modelBase))
27+
{
28+
return;
29+
}
30+
2631
var details = new Dictionary<string, object>()
2732
{
2833
{ "consumer", consumer },
2934
{ "context", "HandleModelShutdown" }
3035
};
31-
model.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
36+
modelBase.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
3237
}
3338
}
3439
}

0 commit comments

Comments
 (0)