Skip to content

Commit

Permalink
pr-fix: correct managed identity connection
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnmoreels committed Nov 14, 2024
1 parent d03caa0 commit 896052b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Arcus.Messaging.Pumps.Abstractions/MessagePump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected MessagePump(IConfiguration configuration, IServiceProvider serviceProv
/// <param name="receiveException">Exception that occurred</param>
protected virtual Task HandleReceiveExceptionAsync(Exception receiveException)
{
Logger.LogCritical(receiveException, "Unable to process message from {EntityPath} with client {ClientId}: {Message}", EntityPath, ClientId, receiveException.Message);
Logger.LogCritical(receiveException, "Unable to process message from {EntityPath} with client {ClientId}: {Message}", EntityPath, ClientId, receiveException);
return Task.CompletedTask;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ private async Task TestEventHubsMessageHandlingAsync(
MessageCorrelationFormat.Hierarchical => CreateSensorEventDataForHierarchical(),
};

using var connection = TemporaryManagedIdentityConnection.Create(_config, _logger);

var options = new WorkerOptions();
configureOptions(options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ await TestServiceBusQueueDeadLetteredMessageAsync(options =>
private async Task TestServiceBusQueueDeadLetteredMessageAsync(Action<WorkerOptions> configureOptions)
{
// Arrange
using var connection = TemporaryManagedIdentityConnection.Create(_config, _logger);

var options = new WorkerOptions();
configureOptions(options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ public async Task ServiceBusQueueMessagePump_WithCustomOperationParentIdProperty
// Arrange
var customOperationParentIdPropertyName = "MyOperationParentId";
var options = new WorkerOptions();
options.AddServiceBusQueueMessagePump(QueueName, HostName,
opt =>
options.AddServiceBusQueueMessagePumpUsingManagedIdentity(QueueName, HostName,
configureMessagePump: opt =>
{
opt.AutoComplete = true;
opt.Routing.Correlation.Format = MessageCorrelationFormat.Hierarchical;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ namespace Arcus.Messaging.Tests.Integration.MessagePump
{
[Collection("Integration")]
[Trait("Category", "Integration")]
public partial class ServiceBusMessagePumpTests : IClassFixture<ServiceBusEntityFixture>
public partial class ServiceBusMessagePumpTests : IClassFixture<ServiceBusEntityFixture>, IDisposable
{
private readonly TestConfig _config;
private readonly ServiceBusConfig _serviceBusConfig;
private readonly TemporaryManagedIdentityConnection _connection;
private readonly ILogger _logger;
private readonly ITestOutputHelper _outputWriter;

Expand All @@ -47,6 +48,7 @@ public ServiceBusMessagePumpTests(ServiceBusEntityFixture entity, ITestOutputHel

_outputWriter = outputWriter;
_logger = new XunitTestLogger(outputWriter);
_connection = TemporaryManagedIdentityConnection.Create(_config, _logger);

QueueName = entity.QueueName;
TopicName = entity.TopicName;
Expand Down Expand Up @@ -100,8 +102,6 @@ private async Task TestServiceBusMessageHandlingAsync(
MessageCorrelationFormat.Hierarchical => CreateOrderServiceBusMessageForHierarchical(),
};

using var connection = TemporaryManagedIdentityConnection.Create(_config, _logger);

var options = new WorkerOptions();
configureOptions(options);

Expand Down Expand Up @@ -251,6 +251,14 @@ private static void AssertReceivedOrderEventDataForW3C(
Assert.NotNull(receivedEventData.CorrelationInfo.OperationId);
Assert.Equal(operationParentId, receivedEventData.CorrelationInfo.OperationParentId);
}

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
_connection?.Dispose();
}
}

public class ServiceBusEntityFixture : IAsyncLifetime
Expand Down

0 comments on commit 896052b

Please sign in to comment.