Skip to content

This operation is not allowed with Wolverine is bootstrapped in MediatorOnly mode #970

@lamelyan

Description

@lamelyan

Describe the bug
Trying to move query logic into handlers. I run the following code and get a message:

This operation is not allowed with Wolverine is bootstrapped in MediatorOnly mode

It sounds like, I can't call IMessage InvokeAsync in MediatorOnly mode...

Here is my set up.

Given this handler:

public class GetProjectsHandler(IQuerySession session)
{
    public async Task<IReadOnlyList<ProjectOverview>> Handle(Guid userId)
    {
        var projects = await session.Query<Project>()
            .Where(p => p.UserId == userId)
            .Select(project => new ProjectOverview
            {
                Id = project.Id,
                UserId = project.UserId,
                Name = project.Name,
                Category = project.Category
            })
            .ToListAsync();

        return projects;
    }
}

when called from the controller:

[HttpGet("/projects", Name = "GetProjects")]
    public async Task<ActionResult<IReadOnlyList<ProjectOverview>>> Get(IMessageBus bus)
    {
        var userId = Guid.Parse(HttpContext.Items["userId"].ToString());

        var projects = await bus.InvokeAsync<IReadOnlyList<ProjectOverview>>(userId);

        return Ok(projects);
    }

I get the following error message:

System.Guid[0]
Invocation failed!
System.InvalidOperationException: This operation is not allowed with Wolverine is bootstrapped in MediatorOnly mode

In Program.cs it's wired like so:

builder.Host.UseWolverine(opts => 
{
    // Automatically Commit Marten transactions
    opts.Policies.AutoApplyTransactions();
    // Using Wolverine as Mediator
    opts.Durability.Mode = DurabilityMode.MediatorOnly;
});

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