Book rating update failedv1.0.0 · JSON Schema
Indicates that Catalog could not apply a feedback-created event because the referenced book was not found.
1. Compensate Orphaned Feedback When Book Is Missing in Catalog
When Catalog API receives FeedbackCreatedIntegrationEvent for a bookId that does not exist (or was deleted), FeedbackCreatedIntegrationEventHandler returns BookUpdatedRatingFailedIntegrationEvent so Rating API deletes the orphaned feedback record.
Payload details
feedbackId: UUID of the feedback record in Rating API that could not be applied.
Example payload
{ "feedbackId": "01960a1b-5e6f-7a01-8a9b-0c1d2e3f4c01"}Using this example
Rating API idempotently removes the orphaned feedback record so review counts and catalog book state remain consistent.
using BookWorm.Chassis.EventBus;using BookWorm.Chassis.EventBus.Idempotency;using BookWorm.Contracts;using Wolverine.Attributes;
// Integration event contract (BookWorm.Contracts)[IntegrationMessageOwner(ServiceName = Services.Catalog, TopicName = "book-rating-failed")][MessageIdentity("BookWorm.Contracts.BookUpdatedRatingFailedIntegrationEvent")]public sealed record BookUpdatedRatingFailedIntegrationEvent(Guid FeedbackId) : IntegrationEvent;
// 1. Emitted by Catalog API when the target book is not foundif (book is null){ await repository.UnitOfWork.SaveEntitiesAsync(ct); return new BookUpdatedRatingFailedIntegrationEvent(@event.FeedbackId);}
// 2. Consumed in Rating API with Wolverine + IIntegrationEventIdempotencyGuardinternal sealed class BookUpdatedRatingFailedIntegrationEventHandler( IFeedbackRepository repository, IIntegrationEventIdempotencyGuard idempotencyGuard){ [WolverineHandler] public async Task Handle( BookUpdatedRatingFailedIntegrationEvent @event, CancellationToken cancellationToken ) { await idempotencyGuard.ExecuteAsync( @event.Id, nameof(BookUpdatedRatingFailedIntegrationEventHandler), async ct => { var feedback = await repository.GetByIdAsync(@event.FeedbackId, ct); if (feedback is not null) { repository.Delete(feedback); await repository.UnitOfWork.SaveEntitiesAsync(ct); } }, cancellationToken: cancellationToken ); }}1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "BookUpdatedRatingFailedIntegrationEvent",
4 "type": "object",
5 "additionalProperties": false,
6 "required": ["id", "creationDate", "feedbackId"],
7 "properties": {
8 "id": {
9 "type": "string",
10 "format": "uuid",
11 "description": "Unique event identifier (UUIDv7) inherited from IntegrationEvent."
12 },
13 "creationDate": {
14 "type": "string",
15 "format": "date-time",
16 "description": "ISO 8601 UTC timestamp when the event was created."
17 },
18 "feedbackId": {
19 "type": "string",
20 "format": "uuid",
21 "description": "Identifier of the feedback that could not be applied."
22 }
23 }
24}
25