<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="@bpmnkit/core" exporterVersion="0.0.23" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.9.0">
  <bpmn:error id="Error_BOOKING_FAILED" name="BOOKING_FAILED" errorCode="BOOKING_FAILED"/>
  <bpmn:process id="travel-booking-saga" name="Travel Booking Saga" isExecutable="true">
    <bpmn:extensionElements>
      <zeebe:versionTag value="1.0.0"/>
    </bpmn:extensionElements>
    <bpmn:startEvent id="trip-requested" name="Trip requested">
      <bpmn:outgoing>Flow_trip-requested_book-trip</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:subProcess id="book-trip" name="Book trip">
      <bpmn:incoming>Flow_trip-requested_book-trip</bpmn:incoming>
      <bpmn:outgoing>Flow_book-trip_send-itinerary</bpmn:outgoing>
      <bpmn:startEvent id="booking-start">
        <bpmn:outgoing>Flow_booking-start_book-flight</bpmn:outgoing>
      </bpmn:startEvent>
      <bpmn:serviceTask id="book-flight" name="Book flight">
        <bpmn:extensionElements>
          <zeebe:taskDefinition type="flight-book"/>
          <zeebe:ioMapping>
            <zeebe:output source="=confirmation" target="flightConfirmation"/>
          </zeebe:ioMapping>
        </bpmn:extensionElements>
        <bpmn:incoming>Flow_booking-start_book-flight</bpmn:incoming>
        <bpmn:outgoing>Flow_book-flight_book-hotel</bpmn:outgoing>
      </bpmn:serviceTask>
      <bpmn:serviceTask id="book-hotel" name="Book hotel">
        <bpmn:extensionElements>
          <zeebe:taskDefinition type="hotel-book"/>
          <zeebe:ioMapping>
            <zeebe:output source="=confirmation" target="hotelConfirmation"/>
          </zeebe:ioMapping>
        </bpmn:extensionElements>
        <bpmn:incoming>Flow_book-flight_book-hotel</bpmn:incoming>
        <bpmn:outgoing>Flow_book-hotel_hotel-ok</bpmn:outgoing>
      </bpmn:serviceTask>
      <bpmn:exclusiveGateway id="hotel-ok" name="Hotel confirmed?" default="Flow_hotel-ok_book-car">
        <bpmn:incoming>Flow_book-hotel_hotel-ok</bpmn:incoming>
        <bpmn:outgoing>Flow_hotel-ok_hotel-unavailable</bpmn:outgoing>
        <bpmn:outgoing>Flow_hotel-ok_book-car</bpmn:outgoing>
      </bpmn:exclusiveGateway>
      <bpmn:endEvent id="hotel-unavailable">
        <bpmn:incoming>Flow_hotel-ok_hotel-unavailable</bpmn:incoming>
        <bpmn:errorEventDefinition errorRef="Error_BOOKING_FAILED"/>
      </bpmn:endEvent>
      <bpmn:serviceTask id="book-car" name="Book rental car">
        <bpmn:extensionElements>
          <zeebe:taskDefinition type="car-book"/>
          <zeebe:ioMapping>
            <zeebe:output source="=confirmation" target="carConfirmation"/>
          </zeebe:ioMapping>
        </bpmn:extensionElements>
        <bpmn:incoming>Flow_hotel-ok_book-car</bpmn:incoming>
        <bpmn:outgoing>Flow_book-car_car-ok</bpmn:outgoing>
      </bpmn:serviceTask>
      <bpmn:exclusiveGateway id="car-ok" name="Car confirmed?" default="Flow_car-ok_trip-booked">
        <bpmn:incoming>Flow_book-car_car-ok</bpmn:incoming>
        <bpmn:outgoing>Flow_car-ok_car-unavailable</bpmn:outgoing>
        <bpmn:outgoing>Flow_car-ok_trip-booked</bpmn:outgoing>
      </bpmn:exclusiveGateway>
      <bpmn:endEvent id="car-unavailable">
        <bpmn:incoming>Flow_car-ok_car-unavailable</bpmn:incoming>
        <bpmn:errorEventDefinition errorRef="Error_BOOKING_FAILED"/>
      </bpmn:endEvent>
      <bpmn:endEvent id="trip-booked">
        <bpmn:incoming>Flow_car-ok_trip-booked</bpmn:incoming>
      </bpmn:endEvent>
      <bpmn:sequenceFlow id="Flow_booking-start_book-flight" sourceRef="booking-start" targetRef="book-flight"/>
      <bpmn:sequenceFlow id="Flow_book-flight_book-hotel" sourceRef="book-flight" targetRef="book-hotel"/>
      <bpmn:sequenceFlow id="Flow_book-hotel_hotel-ok" sourceRef="book-hotel" targetRef="hotel-ok"/>
      <bpmn:sequenceFlow id="Flow_hotel-ok_hotel-unavailable" sourceRef="hotel-ok" targetRef="hotel-unavailable" name="hotel-failed">
        <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">=hotelConfirmation = null</bpmn:conditionExpression>
      </bpmn:sequenceFlow>
      <bpmn:sequenceFlow id="Flow_hotel-ok_book-car" sourceRef="hotel-ok" targetRef="book-car" name="hotel-confirmed"/>
      <bpmn:sequenceFlow id="Flow_book-car_car-ok" sourceRef="book-car" targetRef="car-ok"/>
      <bpmn:sequenceFlow id="Flow_car-ok_car-unavailable" sourceRef="car-ok" targetRef="car-unavailable" name="car-failed">
        <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">=carConfirmation = null</bpmn:conditionExpression>
      </bpmn:sequenceFlow>
      <bpmn:sequenceFlow id="Flow_car-ok_trip-booked" sourceRef="car-ok" targetRef="trip-booked" name="car-confirmed"/>
    </bpmn:subProcess>
    <bpmn:boundaryEvent id="on-booking-failed" name="Booking failed" attachedToRef="book-trip">
      <bpmn:outgoing>Flow_on-booking-failed_cancel-flight</bpmn:outgoing>
      <bpmn:errorEventDefinition errorRef="Error_BOOKING_FAILED"/>
    </bpmn:boundaryEvent>
    <bpmn:serviceTask id="cancel-flight" name="Cancel flight">
      <bpmn:documentation>Idempotent: cancelling a booking that does not exist is a no-op.</bpmn:documentation>
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="flight-cancel"/>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_on-booking-failed_cancel-flight</bpmn:incoming>
      <bpmn:outgoing>Flow_cancel-flight_release-hotel</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:serviceTask id="release-hotel" name="Release hotel hold">
      <bpmn:documentation>Idempotent: releasing a hold that does not exist is a no-op.</bpmn:documentation>
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="hotel-release"/>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_cancel-flight_release-hotel</bpmn:incoming>
      <bpmn:outgoing>Flow_release-hotel_notify-trip-failed</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:serviceTask id="notify-trip-failed" name="Notify traveller: not booked">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="traveller-notify"/>
        <zeebe:taskHeaders>
          <zeebe:header key="template" value="trip-failed"/>
        </zeebe:taskHeaders>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_release-hotel_notify-trip-failed</bpmn:incoming>
      <bpmn:outgoing>Flow_notify-trip-failed_trip-not-booked</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:endEvent id="trip-not-booked" name="Trip not booked">
      <bpmn:incoming>Flow_notify-trip-failed_trip-not-booked</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:serviceTask id="send-itinerary" name="Send itinerary">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="traveller-notify"/>
        <zeebe:taskHeaders>
          <zeebe:header key="template" value="itinerary"/>
        </zeebe:taskHeaders>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_book-trip_send-itinerary</bpmn:incoming>
      <bpmn:outgoing>Flow_send-itinerary_trip-confirmed</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:endEvent id="trip-confirmed" name="Trip confirmed">
      <bpmn:incoming>Flow_send-itinerary_trip-confirmed</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_trip-requested_book-trip" sourceRef="trip-requested" targetRef="book-trip"/>
    <bpmn:sequenceFlow id="Flow_on-booking-failed_cancel-flight" sourceRef="on-booking-failed" targetRef="cancel-flight"/>
    <bpmn:sequenceFlow id="Flow_cancel-flight_release-hotel" sourceRef="cancel-flight" targetRef="release-hotel"/>
    <bpmn:sequenceFlow id="Flow_release-hotel_notify-trip-failed" sourceRef="release-hotel" targetRef="notify-trip-failed"/>
    <bpmn:sequenceFlow id="Flow_notify-trip-failed_trip-not-booked" sourceRef="notify-trip-failed" targetRef="trip-not-booked"/>
    <bpmn:sequenceFlow id="Flow_book-trip_send-itinerary" sourceRef="book-trip" targetRef="send-itinerary"/>
    <bpmn:sequenceFlow id="Flow_send-itinerary_trip-confirmed" sourceRef="send-itinerary" targetRef="trip-confirmed"/>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="travel-booking-saga_di">
    <bpmndi:BPMNPlane id="travel-booking-saga_di_plane" bpmnElement="travel-booking-saga">
      <bpmndi:BPMNShape id="trip-requested_di" bpmnElement="trip-requested">
        <dc:Bounds x="51" y="164" width="36" height="36"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="20" y="204" width="98" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="book-trip_di" bpmnElement="book-trip" isExpanded="true">
        <dc:Bounds x="187" y="20" width="1172" height="324"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="on-booking-failed_di" bpmnElement="on-booking-failed">
        <dc:Bounds x="755" y="326" width="36" height="36"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="724" y="366" width="98" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="cancel-flight_di" bpmnElement="cancel-flight">
        <dc:Bounds x="1459" y="424" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="release-hotel_di" bpmnElement="release-hotel">
        <dc:Bounds x="1659" y="424" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="notify-trip-failed_di" bpmnElement="notify-trip-failed">
        <dc:Bounds x="1859" y="424" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="trip-not-booked_di" bpmnElement="trip-not-booked">
        <dc:Bounds x="2059" y="446" width="36" height="36"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="2025" y="486" width="105" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="send-itinerary_di" bpmnElement="send-itinerary">
        <dc:Bounds x="1459" y="142" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="trip-confirmed_di" bpmnElement="trip-confirmed">
        <dc:Bounds x="1691" y="164" width="36" height="36"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1660" y="204" width="98" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="booking-start_di" bpmnElement="booking-start">
        <dc:Bounds x="237" y="120" width="36" height="36"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="book-flight_di" bpmnElement="book-flight">
        <dc:Bounds x="373" y="98" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="book-hotel_di" bpmnElement="book-hotel">
        <dc:Bounds x="573" y="98" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="hotel-ok_di" bpmnElement="hotel-ok">
        <dc:Bounds x="773" y="113" width="50" height="50"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="742" y="167" width="112" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="hotel-unavailable_di" bpmnElement="hotel-unavailable">
        <dc:Bounds x="955" y="258" width="36" height="36"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="book-car_di" bpmnElement="book-car">
        <dc:Bounds x="923" y="98" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="car-ok_di" bpmnElement="car-ok">
        <dc:Bounds x="1123" y="113" width="50" height="50"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1099" y="167" width="98" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="car-unavailable_di" bpmnElement="car-unavailable">
        <dc:Bounds x="1273" y="258" width="36" height="36"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="trip-booked_di" bpmnElement="trip-booked">
        <dc:Bounds x="1273" y="120" width="36" height="36"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_trip-requested_book-trip_di" bpmnElement="Flow_trip-requested_book-trip">
        <di:waypoint x="87" y="182"/>
        <di:waypoint x="187" y="182"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_on-booking-failed_cancel-flight_di" bpmnElement="Flow_on-booking-failed_cancel-flight">
        <di:waypoint x="773" y="362"/>
        <di:waypoint x="773" y="464"/>
        <di:waypoint x="1459" y="464"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_cancel-flight_release-hotel_di" bpmnElement="Flow_cancel-flight_release-hotel">
        <di:waypoint x="1559" y="464"/>
        <di:waypoint x="1659" y="464"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_release-hotel_notify-trip-failed_di" bpmnElement="Flow_release-hotel_notify-trip-failed">
        <di:waypoint x="1759" y="464"/>
        <di:waypoint x="1859" y="464"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_notify-trip-failed_trip-not-booked_di" bpmnElement="Flow_notify-trip-failed_trip-not-booked">
        <di:waypoint x="1959" y="464"/>
        <di:waypoint x="2059" y="464"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_book-trip_send-itinerary_di" bpmnElement="Flow_book-trip_send-itinerary">
        <di:waypoint x="1359" y="182"/>
        <di:waypoint x="1459" y="182"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_send-itinerary_trip-confirmed_di" bpmnElement="Flow_send-itinerary_trip-confirmed">
        <di:waypoint x="1559" y="182"/>
        <di:waypoint x="1691" y="182"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_booking-start_book-flight_di" bpmnElement="Flow_booking-start_book-flight">
        <di:waypoint x="273" y="138"/>
        <di:waypoint x="373" y="138"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_book-flight_book-hotel_di" bpmnElement="Flow_book-flight_book-hotel">
        <di:waypoint x="473" y="138"/>
        <di:waypoint x="573" y="138"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_book-hotel_hotel-ok_di" bpmnElement="Flow_book-hotel_hotel-ok">
        <di:waypoint x="673" y="138"/>
        <di:waypoint x="773" y="138"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_hotel-ok_hotel-unavailable_di" bpmnElement="Flow_hotel-ok_hotel-unavailable">
        <di:waypoint x="798" y="163"/>
        <di:waypoint x="798" y="276"/>
        <di:waypoint x="955" y="276"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="835" y="252" width="84" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_hotel-ok_book-car_di" bpmnElement="Flow_hotel-ok_book-car">
        <di:waypoint x="823" y="138"/>
        <di:waypoint x="923" y="138"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_book-car_car-ok_di" bpmnElement="Flow_book-car_car-ok">
        <di:waypoint x="1023" y="138"/>
        <di:waypoint x="1123" y="138"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_car-ok_car-unavailable_di" bpmnElement="Flow_car-ok_car-unavailable">
        <di:waypoint x="1148" y="163"/>
        <di:waypoint x="1148" y="276"/>
        <di:waypoint x="1273" y="276"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1176" y="252" width="70" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_car-ok_trip-booked_di" bpmnElement="Flow_car-ok_trip-booked">
        <di:waypoint x="1173" y="138"/>
        <di:waypoint x="1273" y="138"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1178" y="114" width="91" height="14"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

