Skip to content
This repository was archived by the owner on Oct 13, 2024. It is now read-only.
This repository was archived by the owner on Oct 13, 2024. It is now read-only.

compensation method invoke before compensable method #346

@stashslash

Description

@stashslash

i test the saga-spring-demo

if i modify the HotelBookingService add some sleep code, like:

@Compensable(compensationMethod = "cancel", timeout = 5)
  void order(HotelBooking booking) {
    if (booking.getAmount() > 2) {
      throw new IllegalArgumentException("can not order the rooms large than two");
    }
    booking.confirm();

   // sleep 10 sec, simulate slow db
    try {
      Thread.sleep(10 * 1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    bookings.put(booking.getId(), booking);
  }

then, i call the booking rest api, and got the booking result from hotel service and car service, the result looks like:

  • hotel service:
    [{"name":"test","amount":2,"confirmed":true,"cancelled":false}]
  • car service:
    [{"name":"test","amount":2,"confirmed":false,"cancelled":true}]

it's looks like car service compensated success, but hotel service compensated failure.

so, did i missing anything?

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