Skip to content

Commit 1a4466f

Browse files
marius-codezjeremydmiller
authored andcommitted
Add global timeout option for remote invocation
1 parent 8af80f2 commit 1a4466f

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

src/Testing/CoreTests/Acceptance/remote_invocation.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public async Task InitializeAsync()
5151
_sender = await Host.CreateDefaultBuilder()
5252
.UseWolverine(opts =>
5353
{
54+
opts.DefaultRemoteInvocationTimeout = 10.Seconds();
55+
5456
opts.DisableConventionalDiscovery();
5557
opts.ServiceName = "Sender";
5658
opts.ListenAtPort(senderPort);
@@ -302,6 +304,17 @@ public async Task timeout_on_send_and_wait_with_auto_routing()
302304
ex.Message.ShouldContain("Timed out waiting for expected acknowledgement for original message");
303305
}
304306

307+
[Fact]
308+
public async Task no_timeout_on_send()
309+
{
310+
var publisher = _sender.MessageBus();
311+
312+
await Should.NotThrowAsync(async () =>
313+
{
314+
await publisher.InvokeAsync(new Request1 { Name = "FAST" });
315+
});
316+
}
317+
305318
[Fact]
306319
public async Task sad_path_request_and_reply_with_no_handler()
307320
{
@@ -383,7 +396,12 @@ public async Task<Response1> Handle(Request1 request)
383396

384397
if (request.Name == "SLOW")
385398
{
386-
await Task.Delay(5.Seconds());
399+
await Task.Delay(11.Seconds());
400+
}
401+
402+
if (request.Name == "FAST")
403+
{
404+
await Task.Delay(7.Seconds());
387405
}
388406

389407
return new Response1 { Name = request.Name };
@@ -399,7 +417,7 @@ public async Task Handle(Request2 request)
399417

400418
if (request.Name == "SLOW")
401419
{
402-
await Task.Delay(6.Seconds());
420+
await Task.Delay(11.Seconds());
403421
}
404422
}
405423

src/Wolverine/Runtime/Routing/MessageRoute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ internal async Task<T> RemoteInvokeAsync<T>(object message, MessageBus bus, Canc
166166

167167
bus.Runtime.RegisterMessageType(typeof(T));
168168

169-
timeout ??= 5.Seconds();
170-
169+
timeout ??= bus.Runtime.Options.DefaultRemoteInvocationTimeout;
170+
171171
var envelope = new Envelope(message, Sender)
172172
{
173173
TenantId = options?.TenantId ?? bus.TenantId,

src/Wolverine/WolverineOptions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,16 @@ public void RegisterMessageType(Type messageType)
258258
public DurabilitySettings Durability { get; }
259259

260260
/// <summary>
261-
/// The default message execution timeout. This uses a CancellationTokenSource
261+
/// The default message execution timeout for local queues. This uses a CancellationTokenSource
262262
/// behind the scenes, and the timeout enforcement is dependent on the usage within handlers
263263
/// </summary>
264264
public TimeSpan DefaultExecutionTimeout { get; set; } = 60.Seconds();
265265

266+
/// <summary>
267+
/// The default remote invocation timeout over external transport. If a message is not acknowledged within the time specified,
268+
/// it will throw a TimeoutException
269+
/// </summary>
270+
public TimeSpan DefaultRemoteInvocationTimeout { get; set; } = 5.Seconds();
266271

267272
/// <summary>
268273
/// Register additional services to the underlying IoC container with either .NET standard IServiceCollection extension

0 commit comments

Comments
 (0)