CC needs one application that is used by the taxi drivers and one that is used by the customer. The customer should be able to request a taxi via the application, and the taxi driver should be able to accept a request (the ride):
The customer should be able to enter information about the starting point and the endpoint of the trip. Active drivers receive the requests and are able to accept them. The customer should, in the end, be able to follow the location of the taxi during the trip.
The following diagram shows the messaging architecture that CC wants to achieve:
This flow can be explained in 10 steps, as highlighted in the preceding diagram:
- A customer uses CC's mobile application to book a taxi. A request is now sent from the mobile application to the Application Service. This request includes information about the trip that the customer wants to book.
- The Application Service stores the request in a database.
- The Application Service adds a message with information about the trip to a queue in RabbitMQ.
- Connected taxi cars subscribe to the message (the booking request).
- A taxi responds to the customer by sending a message back to RabbitMQ.
- The Application Service subscribes to the messages.
- Again, the Application Service stores the information in a database.
- The Application Service forwards the information to the customer.
- The taxi app starts to automatically send the taxi's geographical location at a given interval to RabbitMQ.
- The location of the taxi is then passed straight to the customer's mobile application, via WebSockets, so that they know when the taxi arrives.
Let's begin by taking a closer look at steps 1, 2, 3, and 4, as shown in the preceding diagram, where a customer requests a taxi (a message is published to RabbitMQ) and a taxi driver receives the request (a message is consumed from RabbitMQ).