Complete the code to send a message to start a saga transaction.
channel.basic_publish(exchange='saga_exchange', routing_key='start', body=[1])
The message body must be a string or bytes representing the order details in JSON format.
Complete the code to acknowledge a message after processing in the saga.
channel.basic_ack(delivery_tag=[1])The delivery tag from the method frame is used to acknowledge the message.
Fix the error in the saga compensation step to publish a rollback message.
channel.basic_publish(exchange='saga_exchange', routing_key=[1], body=rollback_data)
The routing key must be a string specifying the rollback action.
Fill both blanks to declare a durable queue and bind it to the saga exchange.
channel.queue_declare(queue=[1], durable=[2]) channel.queue_bind(queue='saga_queue', exchange='saga_exchange', routing_key='start')
The queue name must be a string and durability should be set to True for persistence.
Fill all three blanks to create a saga step that consumes messages, processes them, and sends a compensation if needed.
def on_message(channel, method, properties, body): data = json.loads(body) if data.get('status') == [1]: process(data) else: channel.basic_publish(exchange='saga_exchange', routing_key=[2], body=json.dumps(data)) channel.basic_ack(delivery_tag=[3])
The saga step processes messages with status 'success', sends rollback messages on failure, and acknowledges using method.delivery_tag.