messaging
БесплатноБез исполняемых скриптовНе проверенAsync messaging for .NET: per-module outbox/inbox for integration events, Hangfire or BackgroundService jobs, forwarding to Azure Service Bus, RabbitMQ Rebus…
от codewithmukesh★ 858 звёзд на GitHubОб этом скилле
Messaging
The per-module outbox code itself lives in skills/modular-slices/references/outbox.md. This skill covers when to use it, how to consume events safely, scheduled jobs, and what to add when events must reach another service.
Core Principles
- Built-in outbox first, broker later. Inside one deployable, modules publish with
db.Publish(evt, clock)into their own outbox table, in the same transaction as the change. A worker delivers events to consumers in other modules. This needs no broker and no library, and it gives the same guarantees a library outbox gives: the event exists if and only if the change committed. - Delivery is at-least-once, effects are exactly-once. The dispatcher retries until a consumer succeeds, so a consumer can see an event twice. Each consumer runs in a transaction with an inbox row keyed by event ID and consumer name, so its effect happens once. Write consumers that are also safe to re-run anyway.
- Events are contracts. They are records in the publisher's
Contractsproject, with IDs and the facts that changed. The full type name is stored in the outbox, so a published event is never renamed or moved; add a new one instead. - Jobs and events are different things. "Something happened, react to it" is an event through the outbox. "Do this every night" is a scheduled job in Hangfire or a
BackgroundService. Do not fake schedules with self-publishing events. - Pick the broker client for what you need, not for what is popular. One or two queues: the Azure Service Bus or RabbitMQ client. Many services with sagas and a transport abstraction: Rebus (MIT), or MassTransit, which requires a commercial licence from v9.
Patterns
Publishing an integration event
// Orders.Contracts/OrderPlaced.cs
/// <summary>Published when an order is placed. Never rename or move: the type name is stored in the outbox.</summary>
public sealed record OrderPlaced(Guid OrderId, decimal Total);
// Orders/Features/PlaceOrder/PlaceOrderHandler.cs
db.Orders.Add(order);
db.Publish(new OrderPlaced(order.Id, order.Total), clock);
await db.SaveChangesAsync(ct); // order row and outbox row commit together
Why: there is no moment where the order is saved but the event is lost, or the event is sent for an order that rolled back.
Consuming in another module
// Billing/Events/InvoiceOrders.cs
internal sealed class InvoiceOrders(BillingDbContext db, TimeProvider clock) : IEventConsumer<OrderPlaced>
{
public async Task ConsumeAsync(OrderPlaced message, CancellationToken ct)
{
// Safe to re-run even without the inbox: check before acting.
if (await db.Invoices.AnyAsync(i => i.OrderId == message.OrderId, ct))
return;
db.Invoices.Add(Invoice.For(message.OrderId, message.Total, clock.GetUtcNow()));
await db.SaveChangesAsync(ct);
}
}
// BillingModule.AddServices
services.AddEventConsumer<OrderPlaced, InvoiceOrders, BillingDbContext>();
Why: the consumer depends only on Orders.Contracts. The third type argument names the consuming module's context, which holds the inbox row and the consumer's changes in one transaction.
Running delivery in the Worker host only
// Worker/Program.cs
var builder = Host.CreateApplicationBuilder(args);
builder.AddServiceDefaults();
builder.AddModule<OrdersModule>();
builder.AddModule<BillingModule>();
builder.Services.AddOutboxWorker(); // BackgroundService polling every module's outbox
builder.Build().Run();
The Api host adds the same modules but not AddOutboxWorker(): it publishes, it does not deliver. Several Worker replicas can run safely because the dispatcher reads with FOR UPDATE SKIP LOCKED.
Tune delivery through the Outbox configuration section (PollInterval, BatchSize, MaxAttempts, retry delays). Failed events stay in the table with failed_at and the exception type, so they can be inspected and replayed by clearing failed_at.
Testing event flows
await client.PostAsJsonAsync("/api/v1/orders", new PlaceOrderRequest(productId, 2), ct);
await fixture.Factory.Services.GetRequiredService<IOutboxDispatcher>().DispatchPendingAsync(ct);
var invoices = await client.GetFromJsonAsync<List<InvoiceResponse>>("/api/v1/billing/invoices", ct);
Assert.Single(invoices!);
Why: tests never start the worker loop. Calling the dispatcher directly makes event delivery deterministic.
Scheduled jobs with Hangfire
// Worker/Program.cs
builder.Services.AddHangfire((provider, config) => config
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UsePostgreSqlStorage(o => o.UseNpgsqlConnection(builder.Configuration.GetConnectionString("app"))));
builder.Services.AddHangfireServer();
// BillingModule: registered after the host starts, e.g. from an IHostedService
recurringJobs.AddOrUpdate<SendOverdueReminders>(
"billing.send-overdue-reminders",
j
Установить messaging в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл messaging?
Async messaging for .NET: per-module outbox/inbox for integration events, Hangfire or BackgroundService jobs, forwarding to Azure Service Bus, RabbitMQ Rebus or MassTransit. Use for "outbox", "inbox", "integration event", "idempotent consumer", "Hangfire", "scheduled job", "Rebus", "MassTransit", "RabbitMQ". Do NOT use for in-process handlers (use modular-slices) or HTTP client retries (use resilience).
Как установить скилл messaging?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл messaging запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic