---
id: BookUpdatedRatingFailedIntegrationEvent
name: Book rating update failed
version: 1.0.0
summary: |
  Indicates that Catalog could not apply a feedback-created event because the
  referenced book was not found.
owners:
  - catalog-experience-team
schemaPath: schema.json
badges:
  - content: Reviews
    backgroundColor: purple
    textColor: purple
---

`BookUpdatedRatingFailedIntegrationEvent` (v1.0.0) is a compensating event published by [[service|catalog-api]] when it receives [[event|FeedbackCreatedIntegrationEvent]] for a book that does not exist in the catalog. [[service|rating-api]] consumes this event to revert and delete the orphaned feedback record.

## Overview

| Property                             | Value                                                                                            |
| :----------------------------------- | :----------------------------------------------------------------------------------------------- |
| **Bounded Context**                  | Catalog (compensating for Reviews)                                                               |
| **Producer**                         | [[service\|catalog-api]]                                                                         |
| **Consumer(s)**                      | [[service\|rating-api]]                                                                          |
| **Protocol / Format**                | Kafka + CloudEvents JSON (camelCase payload)                                                     |
| **Channel / Topic**                  | [[channel\|bookworm.&#123;env&#125;.catalog.book-update-rating-failed]]                          |
| **Dead-Letter Channel**              | [[channel\|bookworm.&#123;env&#125;.rating.dead-letter-queue]]                                   |
| **Partition Key**                    | `FeedbackId`                                                                                     |
| **Delivery / Idempotency Guarantee** | Published via transactional outbox; consumed with Redis-backed 24-hour idempotency keyed by `id` |

## Payload Fields & Envelope

### Event Payload

| Name           | Type                   | Required | Constraints                     | Description                                                                          |
| :------------- | :--------------------- | :------- | :------------------------------ | :----------------------------------------------------------------------------------- |
| `id`           | `string` (`uuid`)      | Yes      | UUIDv7                          | Unique event identifier used by [[service\|rating-api]] as the Redis idempotency key |
| `creationDate` | `string` (`date-time`) | Yes      | ISO 8601 UTC timestamp          | UTC timestamp when the event was created                                             |
| `feedbackId`   | `string` (`uuid`)      | Yes      | Valid UUID; Kafka partition key | Identifier of the orphaned [[entity\|feedback]] record to revert and delete          |

### CloudEvents Envelope Headers

| Header        | Value / Source                                                      | Purpose                                                       |
| :------------ | :------------------------------------------------------------------ | :------------------------------------------------------------ |
| `messagetype` | `BookWorm.Contracts.BookUpdatedRatingFailedIntegrationEvent`        | Explicit message identity for cross-service deserialization   |
| `source`      | `urn:bookworm:bookworm-catalog`                                     | Identifies the producing service                              |
| `requestid`   | Propagated from incoming [[event\|FeedbackCreatedIntegrationEvent]] | Traces compensation back to the originating review submission |

## Delivery Guarantees & Error Handling

| Condition                          | System Behavior                                                                   | Recovery / Compensation                                                                    |
| :--------------------------------- | :-------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------- |
| Duplicate delivery within 24 hours | Consumer skips reprocessing via Redis-backed 24-hour idempotency keyed by `id`    | Safe at-least-once delivery                                                                |
| Feedback record already deleted    | Consumer returns without error                                                    | No action required; compensation is naturally idempotent                                   |
| Transient store or network failure | Retried with cooldown (`50ms`, `250ms`, `1s`) and full jitter                     | Exhausted messages route to [[channel\|bookworm.&#123;env&#125;.rating.dead-letter-queue]] |
| Deserialization failure            | Routed directly to [[channel\|bookworm.&#123;env&#125;.rating.dead-letter-queue]] | Inspect dead-letter payload against contract schema                                        |

## Related Documentation

- [[channel|bookworm.&#123;env&#125;.catalog.book-update-rating-failed]] — Kafka channel specification.
- [[channel|bookworm.&#123;env&#125;.rating.dead-letter-queue]] — Dead-letter channel for failed Rating consumers.
- [[event|FeedbackCreatedIntegrationEvent]] — Upstream event that triggers this compensation when a book is missing.
- [[service|catalog-api]] — Producer service.
- [[service|rating-api]] — Consumer service owning feedback records.
- [[entity|feedback]] — Feedback document schema.

<NodeGraph />

<SchemaViewer
	file="schema.json"
	title="Book rating update failed schema"
	maxHeight="500"
	search="true"
/>


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "BookUpdatedRatingFailedIntegrationEvent",
	"type": "object",
	"additionalProperties": false,
	"required": ["id", "creationDate", "feedbackId"],
	"properties": {
		"id": {
			"type": "string",
			"format": "uuid",
			"description": "Unique event identifier (UUIDv7) inherited from IntegrationEvent."
		},
		"creationDate": {
			"type": "string",
			"format": "date-time",
			"description": "ISO 8601 UTC timestamp when the event was created."
		},
		"feedbackId": {
			"type": "string",
			"format": "uuid",
			"description": "Identifier of the feedback that could not be applied."
		}
	}
}
