When a booking request is received, publish a message to RabbitMQ containing the booking details (bookingId, runnerId, proposedSlot) for runner assignment.
Runner Assignment (Message Consumer):
Implement a consumer to receive and process runner assignment messages.
Runners can either accept the request (confirmation: true) or propose an alternative slot/runner (confirmation: false with proposed details).
Confirmation Email Trigger:
Upon receiving an acceptance confirmation from a runner, trigger confirmation emails to the customer and runner.
Integration with RabbitMQ (Example)
// Publishing runner assignment message
public void PublishRunnerAssignmentMessage(string bookingId, string runnerId, string proposedSlot)
{
var message = new
{
bookingId,
runnerId,
proposedSlot
};
var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message));
_channel.BasicPublish(exchange: "",
routingKey: "runnerAssignmentQueue",
basicProperties: null,
body: body);
}
// Consuming runner assignment messages
public void ConsumeRunnerAssignmentMessages()
{
var consumer = new EventingBasicConsumer(_channel);
consumer.Received += (model, ea) =>
{
var body = ea.Body.ToArray();
var message = Encoding.UTF8.GetString(body);
var assignmentMessage = JsonConvert.DeserializeObject<RunnerAssignmentMessage>(message);
// Process runner assignment (acceptance or propose alternative)
ProcessRunnerAssignment(assignmentMessage);
_channel.BasicAck(ea.DeliveryTag, false);
};
_channel.BasicConsume(queue: "runnerAssignmentQueue",
autoAck: false,
consumer: consumer);
}
Additional Notes
Ensure proper error handling and message acknowledgment mechanisms are implemented for reliable message processing.
Integrate with email service or notification system to trigger confirmation emails upon runner acceptance of booking requests.
Description
Implement message queues and consumers to process runner responses asynchronously, sending confirmation emails upon acceptance of booking requests.
RabbitMQ Message Payloads:
Define message payloads for runner assignment and confirmation messages.
When a booking request is received, publish a message to RabbitMQ containing the booking details (bookingId, runnerId, proposedSlot) for runner assignment.
Implement a consumer to receive and process runner assignment messages. Runners can either accept the request (confirmation: true) or propose an alternative slot/runner (confirmation: false with proposed details).
Upon receiving an acceptance confirmation from a runner, trigger confirmation emails to the customer and runner.
Integration with RabbitMQ (Example)
Additional Notes
Ensure proper error handling and message acknowledgment mechanisms are implemented for reliable message processing.
Integrate with email service or notification system to trigger confirmation emails upon runner acceptance of booking requests.