A lightweight in-memory message queue transport for CAP.
Designed ONLY for local development, demos and automated tests. Do not use in production.
dotnet add package Savorboard.CAP.InMemoryMessageQueue- Zero external dependencies
- Works entirely in-memory (lifetime = process lifetime)
- Publish / subscribe via standard CAP attributes
- Fast startup, simple to configure
- Great for unit / integration tests
- .NET 8 compatible
Not persistent. Not cross-process. Not clustered. Not durable. Not for performance benchmarking. Not for production. If the process stops, messages are gone.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCap(options =>
{
options.DefaultGroup = "demo.group";
options.UseInMemoryMessageQueue();
// You can still configure a persistent storage component if needed.
});
var app = builder.Build();
app.MapGet("/publish", async (ICapPublisher cap) =>
{
await cap.PublishAsync("demo.topic", new { Id = Guid.NewGuid(), Time = DateTimeOffset.UtcNow });
return "Published";
});
app.Run();Subscriber example:
public class DemoSubscriber
{
[CapSubscribe("demo.topic")]
public void Handle(dynamic payload)
{
Console.WriteLine($"Received: {payload.Id} at {payload.Time}");
}
}Currently no extra tunable options:
options.UseInMemoryMessageQueue();See samples/InMemorySample for a minimal runnable example.
dotnet testIssues and PRs welcome. Keep changes small and focused.
MIT
Use for development & tests only. Switch to a real queue for production workloads.