0Pricing
RabbitMQ Messaging & Async Systems · Lektion

Transaktionen vs. Publisher Confirms

Vergleichen Sie AMQP-Transaktionen mit dem schlankeren Mechanismus der Publisher Confirms und lernen Sie, wann welcher Mechanismus die sichere Annahme einer Nachricht durch den Broker garantiert.

Transaktionen vs. Publisher Confirms ist eine kostenlose RabbitMQ Messaging & Async Systems-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des RabbitMQ Messaging & Async Systems-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der RabbitMQ Messaging & Async Systems-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Why Reliability Needs More Than Persistence

Persistent messages survive a broker restart, but persistence alone does not tell the publisher whether the broker actually received and stored the message.

For end-to-end reliability you need confirmation.

AMQP Transactions

AMQP supports transactions on a channel: you begin a transaction, publish messages, then commit. The broker confirms the whole batch atomically.

Using a Transaction

Enable transaction mode with tx_select, publish, then tx_commit.

channel.tx_select()
channel.basic_publish(exchange='', routing_key='jobs', body='task')
channel.tx_commit()

The Cost of Transactions

Transactions are synchronous and slow. Each commit blocks until the broker responds, often cutting throughput by 200x or more.

They serialize publishing, which kills pipelining.

Publisher Confirms Recap

Publisher confirms are an asynchronous alternative. The broker sends an ack per message (or per batch) once it is safely handled, without blocking the publisher.

Enabling Confirm Mode

Put the channel into confirm mode once; you cannot mix it with transaction mode on the same channel.

channel.confirm_delivery()
channel.basic_publish(exchange='', routing_key='jobs', body='task')

Asynchronous Acks

With confirms you can keep publishing while acks arrive in the background, then match acks to delivery tags. This preserves high throughput.

Handling Nacks

If the broker cannot handle a message it sends a nack. Your code must resend or log it. Nacks are rare but signal internal broker errors.

Choosing Between Them

  • Transactions: true atomic multi-message commit, but very slow
  • Confirms: near-equivalent safety with far higher throughput

The RabbitMQ team recommends confirms for almost all cases.

Combine With Persistence

For the strongest guarantee, mark messages persistent and use confirms; the broker only acks a persistent message after it is written to disk.

props = pika.BasicProperties(delivery_mode=2)
channel.basic_publish(exchange='', routing_key='jobs', body='task', properties=props)

Mutually Exclusive Modes

A single channel cannot be in both transaction and confirm mode. Pick one per channel; attempting both raises a channel error.

Quick Check

Test your reliability knowledge.

Recap

Both transactions and publisher confirms tell a publisher the broker accepted a message.

Transactions are atomic but slow; confirms are asynchronous and fast. Combine confirms with persistent messages for the best balance of reliability and performance.

Häufig gestellte Fragen

Ist die Lektion „Transaktionen vs. Publisher Confirms“ kostenlos?

Ja — der vollständige Text von „Transaktionen vs. Publisher Confirms“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des RabbitMQ Messaging & Async Systems-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der RabbitMQ Messaging & Async Systems-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Transaktionen vs. Publisher Confirms“?

Vergleichen Sie AMQP-Transaktionen mit dem schlankeren Mechanismus der Publisher Confirms und lernen Sie, wann welcher Mechanismus die sichere Annahme einer Nachricht durch den Broker garantiert. Du übst RabbitMQ Messaging & Async Systems mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um RabbitMQ Messaging & Async Systems zu starten?

Keine Vorkenntnisse erforderlich. RabbitMQ Messaging & Async Systems auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Transaktionen vs. Publisher Confirms“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser RabbitMQ Messaging & Async Systems-Lektion Code schreiben und ausführen?

Ja. Jede RabbitMQ Messaging & Async Systems-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Persistente Nachrichten und Queues
  2. Publisher Confirms für Zuverlässigkeit
  3. Consumer-Bestätigungen und erneutes Einreihen
  4. Transaktionen vs. Publisher Confirms
← Zurück zu RabbitMQ Messaging & Async Systems