Skip to content

No listener when AlwaysPublishResponse attribute and .InvokeAsync<T> are used #1306

@Damix48

Description

@Damix48

Describe the bug
AlwaysPublishResponse not working. No listener for the returned message:

fail: Wolverine.Runtime.RemoteInvocation.ReplyTracker[0]
      Unable to find a registered reply listener for conversation id 08dd61a8-8a72-8c03-5847-ca716e1c0000 with message type Message2. The listener may have previously timed out

To Reproduce
In the following code if you call the /message1return endpoint only the Message1Handler is called. It seems that the Message2Handler is not registered.

Code example
using Wolverine;
using Wolverine.Attributes;

var builder = WebApplication.CreateBuilder(args);

builder.Host.UseWolverine();
builder.Services.AddOpenApi();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.MapOpenApi();
}

app.UseHttpsRedirection();

app.MapGet("/message1",async(IMessageBus messageBus) =>
{
    await messageBus.InvokeAsync(new Message1());
});

app.MapGet("/message1return",async(IMessageBus messageBus) =>
{
    var result = await messageBus.InvokeAsync<Message2>(new Message1());
    
    Console.WriteLine(result.GetType());
    
    return result;
});

app.Run();

public record Message1();
public record Message2();
public record Message3();

public static class Message1Handler
{
    [AlwaysPublishResponse]
    public static Message2 Handle(Message1 request, IMessageBus messageBus)
    {
        Console.WriteLine("Message1Handler");

        return new Message2();
    }
}

public static class Message2Handler
{
    public static Message3 Handle(Message2 request, IMessageBus messageBus)
    {
        Console.WriteLine("Message2Handler");

        return new Message3();
    }
}

public static class Message3Handler
{
    public static void Handle(Message3 request, IMessageBus messageBus)
    {
        Console.WriteLine("Message3Handler");
    }
}

Expected behavior
A clear and concise description of what you expected to happen.

Versions:

  • Wolverine: 3.10.4 (tested other version from 3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions