0
0
RabbitMQdevops~20 mins

Batch publishing for throughput in RabbitMQ - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Batch Publishing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why use batch publishing in RabbitMQ?

Imagine you want to send many messages quickly to RabbitMQ. Why is batch publishing better than sending messages one by one?

ABatch publishing encrypts messages for security by default.
BBatch publishing guarantees message order better than single message publishing.
CBatch publishing reduces network overhead by sending multiple messages in one go, improving throughput.
DBatch publishing automatically retries failed messages without extra code.
Attempts:
2 left
💡 Hint

Think about how sending many small packages separately compares to sending one big package.

💻 Command Output
intermediate
1:30remaining
Output of batch publish with confirms enabled

What will be the output of this Python code snippet using pika library when batch publishing 3 messages with confirms enabled?

RabbitMQ
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='test')
channel.confirm_delivery()
for i in range(3):
    channel.basic_publish(exchange='', routing_key='test', body=f'Message {i}')
print('All messages published')
connection.close()
AAll messages published
BUnroutable message error
CTimeout error waiting for confirms
DSyntaxError
Attempts:
2 left
💡 Hint

Confirm delivery waits for broker acknowledgments after publishing.

Configuration
advanced
2:00remaining
Configuring RabbitMQ publisher confirms for batch publishing

Which configuration snippet correctly enables publisher confirms in RabbitMQ using the Java client for batch publishing?

RabbitMQ
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
// What line enables confirms?
Achannel.enableConfirms(true);
Bchannel.confirmSelect();
Cchannel.setPublisherConfirms(true);
Dchannel.startConfirmMode();
Attempts:
2 left
💡 Hint

Look for the official method name to enable confirms on a channel.

Troubleshoot
advanced
1:30remaining
Troubleshooting slow batch publishing in RabbitMQ

You notice batch publishing is slower than expected. Which of these is the most likely cause?

ANot declaring the exchange before publishing.
BPublishing messages without setting a routing key.
CUsing a non-persistent delivery mode for messages.
DUsing synchronous confirms for each message instead of batch confirms.
Attempts:
2 left
💡 Hint

Think about waiting for acknowledgments after every message versus after a batch.

🔀 Workflow
expert
2:30remaining
Correct order of steps for efficient batch publishing with confirms

Arrange these steps in the correct order to implement efficient batch publishing with confirms in RabbitMQ.

A1,2,3,4
B2,1,3,4
C1,3,2,4
D2,3,1,4
Attempts:
2 left
💡 Hint

Think about setup first, then publishing, then waiting for confirms, then handling errors.