Feedback createdv1.0.0 · JSON Schema
Indicates that a customer feedback rating was created for a book. Rating API publishes this event so Catalog can update its denormalized rating summary.
1. Propagate a New 5-Star Rating to Catalog
After Rating API persists a new feedback record, it dispatches FeedbackCreatedIntegrationEvent so Catalog API increments the book’s AverageRating and TotalReviews.
Payload details
bookId: UUID of the reviewed book in Catalog API.rating: Integer rating from0through5.feedbackId: UUID of the created feedback record in Rating API.
Example payload
{ "bookId": "01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a10", "rating": 5, "feedbackId": "01960a1b-5e6f-7a01-8a9b-0c1d2e3f4c01"}Using this example
Catalog API updates the book’s rating aggregates transactionally. If the target bookId does not exist, Catalog API emits BookUpdatedRatingFailedIntegrationEvent so Rating API compensates by removing the orphaned feedback.
using BookWorm.Chassis.EventBus;using BookWorm.Chassis.EventBus.Dispatcher;using BookWorm.Chassis.EventBus.Idempotency;using BookWorm.Contracts;using Wolverine.Attributes;
// Integration event contract (BookWorm.Contracts)[IntegrationMessageOwner(ServiceName = Services.Rating, TopicName = "feedback-create")][MessageIdentity("BookWorm.Contracts.FeedbackCreatedIntegrationEvent")]public sealed record FeedbackCreatedIntegrationEvent(Guid BookId, int Rating, Guid FeedbackId) : IntegrationEvent;
// 1. Publishing from Rating API via BookWorm.Chassis IEventDispatcherawait eventDispatcher.DispatchAsync( new FeedbackCreatedEvent(feedback.BookId, feedback.Rating, feedback.Id), cancellationToken);
// 2. Consuming in Catalog API with Wolverine + IIntegrationEventIdempotencyGuardinternal sealed class FeedbackCreatedIntegrationEventHandler( IBookRepository repository, IIntegrationEventIdempotencyGuard? idempotencyGuard = null){ [WolverineHandler] public async Task<BookUpdatedRatingFailedIntegrationEvent?> Handle( FeedbackCreatedIntegrationEvent @event, CancellationToken cancellationToken ) { return await idempotencyGuard.ExecuteAsync( @event.Id, nameof(FeedbackCreatedIntegrationEventHandler), async ct => { var book = await repository.GetByIdAsync(@event.BookId, ct); if (book is null) { await repository.UnitOfWork.SaveEntitiesAsync(ct); return new BookUpdatedRatingFailedIntegrationEvent(@event.FeedbackId); }
book.AddRating(@event.Rating); await repository.UnitOfWork.SaveEntitiesAsync(ct); return null; }, cancellationToken: cancellationToken ); }}1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "FeedbackCreatedIntegrationEvent",
4 "type": "object",
5 "additionalProperties": false,
6 "required": ["id", "creationDate", "bookId", "rating", "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 "bookId": {
19 "type": "string",
20 "format": "uuid",
21 "description": "Identifier of the book whose rating summary changes."
22 },
23 "rating": {
24 "type": "integer",
25 "minimum": 0,
26 "maximum": 5,
27 "description": "Rating value added to the book."
28 },
29 "feedbackId": {
30 "type": "string",
31 "format": "uuid",
32 "description": "Identifier of the feedback record."
33 }
34 }
35}
36