Skip to content

templates: generated glue still publishes beside the write - the bare Producer.sendToTopic sites contradict the outbox and stay event-loss windows #6867

Description

@delchev

#6854 established the contract for announcing an entity change: hand the topic to the WRITE (save(entity, topic), update(entity, topic, extraEvents), updateProperties(id, values, topic), ...), so the row and its event commit or roll back together and a briefly-down broker delays the event instead of losing it. Its guide text states the doctrine: "Announce an entity change through its repository, not by publishing next to it."

The generated glue still ships the pre-outbox idiom - a targeted write followed by a bare Producer.sendToTopic beside it. Each site is a live instance of #6816's failure class (row committed, event lost forever, downstream reactions silently never run), now also a contradiction of the platform's own doctrine. Inventory on current master (template-application-events-java events/ unless noted):

Fix: substitute the outbox write - updateProperties(id, values, "<topic>") - for the write-then-publish pairs; the post-commit re-read (which a concurrent write can move) disappears with it, since the outbox payload is the row as the transaction left it, read back on the write's own connection.

The -rekeyed pair is the one non-trivial site: ONE targeted write must record TWO events (the pre-write snapshot naming the vacated group, the written row naming the joined one), and only update(entity, topic, extraEvents) accepts extra events today. The targeted path needs the same capacity - updateProperties(id, values, topic, extraEvents) (or accepting explicit DomainEvents) - so the rekey signals ride the outbox too.

Follow-up to #6854 / #6816; touches the outputs of #6836, #6841, #6845.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions