-
-
Notifications
You must be signed in to change notification settings - Fork 224
Closed
Description
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
Labels
No labels