Skip to content

Commit 278bb0d

Browse files
committed
Fix auto-recovery issue
1 parent 95ff4d6 commit 278bb0d

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

samples/ArtemisNetClient.Examples.AspNetCore/Startup.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class Startup
1919
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
2020
public void ConfigureServices(IServiceCollection services)
2121
{
22-
services.AddActiveMq(name: "my-artemis-cluster", endpoints: new[] { Endpoint.Create(host: "localhost", port: 5672, "guest", "guest") })
22+
services.AddActiveMq(name: "my-artemis-cluster", endpoints: new[] { Endpoint.Create(host: "localhost", port: 5672, "artemis", "artemis") })
2323
.ConfigureConnectionFactory((provider, factory) =>
2424
{
2525
factory.LoggerFactory = provider.GetService<ILoggerFactory>();
@@ -58,8 +58,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5858
{
5959
endpoints.MapGet("/", async context =>
6060
{
61-
var messageProducer = context.RequestServices.GetService<MyTypedMessageProducer>();
62-
await messageProducer.SendTextAsync(DateTime.UtcNow.ToString(CultureInfo.InvariantCulture));
61+
var messageProducer = context.RequestServices.GetRequiredService<MyTypedMessageProducer>();
62+
await messageProducer.SendTextAsync(DateTime.UtcNow.ToString(CultureInfo.InvariantCulture));
6363
await context.Response.WriteAsync("Hello World!");
6464
});
6565
});

src/ArtemisNetClient/AutoRecovering/AutoRecoveringConnection.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,14 @@ public async ValueTask DisposeAsync()
238238
private async Task DisposeInnerConnection()
239239
{
240240
_connection.ConnectionClosed -= OnConnectionClosed;
241-
await _connection.DisposeAsync().ConfigureAwait(false);
241+
try
242+
{
243+
await _connection.DisposeAsync().ConfigureAwait(false);
244+
}
245+
catch (Exception)
246+
{
247+
// ignored
248+
}
242249
}
243250

244251
private Endpoint GetCurrentEndpoint(Context context)

0 commit comments

Comments
 (0)