Send order cancelled notificationv1.0.0 · JSON Schema
Shared Finance cancellation command consumed by Notification to render and submit a canceled-order email.
1. Send an Order Cancellation Email
After Ordering API transitions an order to Cancelled and emits OrderStatusChangedToCancelIntegrationEvent, Notification consumes CancelOrderCommand to render and send a cancellation email.
Payload details
id: UUIDv7 generated byIntegrationEvent(Guid.CreateVersion7()).creationDate: UTC ISO 8601 timestamp (DateTime.UtcNow).orderId: UUID of the cancelled order (used as the Kafka partition key).fullName: Optional customer display name (nulldefaults to"Customer"in Notification).email: Optional recipient email address (nullor whitespace skips SMTP delivery).totalMoney: Order total (decimal).
Example payload
{ "id": "01960a1b-6a01-7b00-8a9b-0c1d2e3f4d01", "creationDate": "2026-11-25T16:20:00Z", "orderId": "01960a1b-3c4d-7e00-8a9b-0c1d2e3f4a99", "fullName": "Minh Nguyen", "email": "minh.nguyen@bookworm.dev", "totalMoney": 59.98}Using this example
Notification deduplicates by command.Id for 24 hours, renders the cancellation MJML email template, and hands the message off to SMTP (Mailpit locally or SendGrid in production).
using BookWorm.Chassis.EventBus;using BookWorm.Chassis.EventBus.Idempotency;using BookWorm.Contracts;using Wolverine;using Wolverine.Attributes;
// Integration command contract (BookWorm.Contracts)public sealed record CancelOrderCommand( Guid OrderId, string? FullName, string? Email, decimal TotalMoney) : IntegrationEvent;
// 1. Publishing via Wolverine IMessageBusawait bus.PublishAsync( new CancelOrderCommand( Guid.Parse("01960a1b-3c4d-7e00-8a9b-0c1d2e3f4a99"), "Minh Nguyen", "minh.nguyen@bookworm.dev", 59.98m ));
// 2. Consuming in Notification with Wolverine + IIntegrationEventIdempotencyGuardinternal sealed class CancelOrderCommandHandler( ISender sender, IIntegrationEventIdempotencyGuard idempotencyGuard){ [WolverineHandler] public async Task Handle(CancelOrderCommand command, CancellationToken cancellationToken) { await idempotencyGuard.ExecuteAsync( command.Id, nameof(CancelOrderCommandHandler), async ct => { if (!string.IsNullOrWhiteSpace(command.Email)) { await sender.SendEmailAsync(command, ct); } }, cancellationToken: cancellationToken ); }}1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "CancelOrderCommand",
4 "type": "object",
5 "additionalProperties": false,
6 "required": ["id", "creationDate", "orderId", "totalMoney"],
7 "properties": {
8 "id": { "type": "string", "format": "uuid" },
9 "creationDate": { "type": "string", "format": "date-time" },
10 "orderId": { "type": "string", "format": "uuid" },
11 "fullName": { "type": ["string", "null"] },
12 "email": { "type": ["string", "null"] },
13 "totalMoney": { "type": "number" }
14 }
15}
16