Spring Core

Exercise: Booking Application

  1. Clone the GitLab repository Booking and create a Postgres database booking.
  2. Implement a transactional travel service that allows customers to make travel bookings that consist of a flight and a hotel booking:
    • Flights and hotels are booked separately by the booking service
    • If one booking fails, the whole travel booking is canceled
    • The booking attempt and possible failures are logged using the logging service e.g.
      Book travel to London for Bob and Error: Hotels in London booked out
  3. Run the TravelServiceIT integration test to test the service.
  4. Set the logging level of the org.springframework.orm.jpa.JpaTransactionManager class to DEBUG and check the transaction management log.
  5. Implement an asynchronous travel service that allows customers to book travels by sending a message (e.g. Bob:London) to a booking queue.
  6. Run the AsyncTravelServiceIT integration test to test the service.
  7. Observe the different behavior depending on whether the listener method is transactional or not.

Solution