Skip to content

Commit 487a4db

Browse files
authored
Revert "Created ConsumerCancelled event on ConsumerCancellation class to be fired when a consumer has been canced by the broker" (#912)
This reverts commit d30c051
1 parent 98e2c5f commit 487a4db

File tree

5 files changed

+8
-40
lines changed

5 files changed

+8
-40
lines changed
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-

2-
using System;
1+
using System;
32

43
namespace EasyNetQ.Consumer
54
{
65
public class ConsumerCancellation : IDisposable
76
{
8-
9-
public delegate void ConsumerCancel(object queue);
10-
// This event will fire whenever this class is disposed. It is necessary in order to catch
11-
// when the consumer is canceled by the broker as well as the user.
12-
public event ConsumerCancel ConsumerCancelled;
13-
147
private readonly Action onCancellation;
158

169
public ConsumerCancellation(Action onCancellation)
@@ -24,10 +17,5 @@ public void Dispose()
2417
{
2518
onCancellation();
2619
}
27-
28-
public void OnCancel(object queue)
29-
{
30-
ConsumerCancelled?.Invoke(queue);
31-
}
3220
}
3321
}

Source/EasyNetQ/Consumer/ExclusiveConsumer.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ public class ExclusiveConsumer : IConsumer
2727

2828
private readonly IList<IDisposable> disposables = new List<IDisposable>();
2929

30-
private ConsumerCancellation consumerCancellation;
31-
3230
public ExclusiveConsumer(
3331
IQueue queue,
3432
Func<byte[], MessageProperties, MessageReceivedInfo, Task> onMessage,
@@ -60,9 +58,8 @@ public IDisposable StartConsuming()
6058
disposables.Add(Timers.Start(s => StartConsumingInternal(), RestartConsumingPeriod, RestartConsumingPeriod));
6159

6260
StartConsumingInternal();
63-
64-
consumerCancellation = new ConsumerCancellation(Dispose);
65-
return consumerCancellation;
61+
62+
return new ConsumerCancellation(Dispose);
6663
}
6764

6865
private void StartConsumingInternal()
@@ -118,9 +115,7 @@ public void Dispose()
118115
return;
119116

120117
disposed = true;
121-
122-
consumerCancellation.OnCancel(queue);
123-
118+
124119
eventBus.Publish(new StoppedConsumingEvent(this));
125120

126121
foreach (var disposal in disposables)

Source/EasyNetQ/Consumer/PersistentConsumer.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class PersistentConsumer : IConsumer
2222

2323
private readonly IList<IDisposable> subscriptions = new List<IDisposable>();
2424

25-
private ConsumerCancellation consumerCancellation;
26-
2725
public PersistentConsumer(
2826
IQueue queue,
2927
Func<byte[], MessageProperties, MessageReceivedInfo, Task> onMessage,
@@ -54,8 +52,7 @@ public IDisposable StartConsuming()
5452

5553
StartConsumingInternal();
5654

57-
consumerCancellation = new ConsumerCancellation(Dispose);
58-
return consumerCancellation;
55+
return new ConsumerCancellation(Dispose);
5956
}
6057

6158
private void StartConsumingInternal()
@@ -104,8 +101,6 @@ public void Dispose()
104101

105102
disposed = true;
106103

107-
consumerCancellation.OnCancel(queue);
108-
109104
eventBus.Publish(new StoppedConsumingEvent(this));
110105

111106
foreach (var subscription in subscriptions)

Source/EasyNetQ/Consumer/PersistentMultipleConsumer.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public class PersistentMultipleConsumer : IConsumer
2323

2424
private readonly IList<IDisposable> subscriptions = new List<IDisposable>();
2525

26-
private ConsumerCancellation consumerCancellation;
27-
2826
public PersistentMultipleConsumer(
2927
ICollection<Tuple<IQueue, Func<byte[], MessageProperties, MessageReceivedInfo, Task>>> queueConsumerPairs,
3028
IPersistentConnection connection,
@@ -52,8 +50,7 @@ public IDisposable StartConsuming()
5250

5351
StartConsumingInternal();
5452

55-
consumerCancellation = new ConsumerCancellation(Dispose);
56-
return consumerCancellation;
53+
return new ConsumerCancellation(Dispose);
5754
}
5855

5956
private void StartConsumingInternal()
@@ -95,9 +92,7 @@ public void Dispose()
9592
if (disposed) return;
9693

9794
disposed = true;
98-
99-
consumerCancellation.OnCancel(queueConsumerPairs);
100-
95+
10196
eventBus.Publish(new StoppedConsumingEvent(this));
10297

10398
foreach (var subscription in subscriptions)

Source/EasyNetQ/Consumer/TransientConsumer.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ public class TransientConsumer : IConsumer
1616

1717
private IInternalConsumer internalConsumer;
1818

19-
private ConsumerCancellation consumerCancellation;
20-
2119
public TransientConsumer(
2220
IQueue queue,
2321
Func<byte[], MessageProperties, MessageReceivedInfo, Task> onMessage,
@@ -60,8 +58,7 @@ public IDisposable StartConsuming()
6058
else
6159
eventBus.Publish(new StartConsumingFailedEvent(this, queue));
6260

63-
consumerCancellation = new ConsumerCancellation(Dispose);
64-
return consumerCancellation;
61+
return new ConsumerCancellation(Dispose);
6562
}
6663

6764
private bool disposed;
@@ -71,8 +68,6 @@ public void Dispose()
7168
if (disposed) return;
7269
disposed = true;
7370

74-
consumerCancellation.OnCancel(queue);
75-
7671
eventBus.Publish(new StoppedConsumingEvent(this));
7772

7873
internalConsumer?.Dispose();

0 commit comments

Comments
 (0)