Skip to content

Commit 04ee2e4

Browse files
committed
Fix unauthorized producer creation attempts cause log flooding and unresponsiveness
1 parent 5319fb2 commit 04ee2e4

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/ArtemisNetClient/AutoRecovering/AutoRecoveringProducer.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Threading.Tasks;
44
using ActiveMQ.Artemis.Client.Exceptions;
55
using ActiveMQ.Artemis.Client.Transactions;
6+
using Amqp;
67
using Microsoft.Extensions.Logging;
78

89
namespace ActiveMQ.Artemis.Client.AutoRecovering
@@ -28,6 +29,13 @@ public async Task SendAsync(Message message, Transaction transaction, Cancellati
2829
await _producer.SendAsync(message, transaction, cancellationToken).ConfigureAwait(false);
2930
return;
3031
}
32+
catch (ProducerClosedException e) when (e.ErrorCode == ErrorCode.UnauthorizedAccess)
33+
{
34+
await TerminateAsync(e).ConfigureAwait(false);
35+
36+
// Producer does not have have permissions to send on specified address
37+
throw;
38+
}
3139
catch (ProducerClosedException)
3240
{
3341
HandleProducerClosed();

src/ArtemisNetClient/ProducerBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ private void CheckState()
136136
}
137137
if (_senderLink.IsDetaching() || _senderLink.IsClosed)
138138
{
139+
if (_senderLink.Error != null)
140+
{
141+
throw new ProducerClosedException(_senderLink.Error.Description, _senderLink.Error.Condition, null);
142+
}
139143
throw new ProducerClosedException();
140144
}
141145
}

0 commit comments

Comments
 (0)