← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Message Broker

messaging Intermediate

TL;DR

A message broker is middleware that receives, routes, and delivers messages between producers and consumers — decoupling services and enabling async communication at scale.

Explanation

Message brokers: Kafka (high-throughput log, replay), RabbitMQ (feature-rich routing, AMQP), Redis Streams (lightweight, Kafka-like), SQS/SNS (AWS managed). Core concepts: producer sends to broker, consumer reads from queue/topic, broker persists until acknowledged. Benefits: decoupling (producers don't know consumers), durability (messages persist), load levelling, retries, dead letter queues. Patterns: point-to-point queue (one consumer gets each message), pub/sub topic (all subscribers get each message). PHP: php-amqplib (RabbitMQ), rdkafka, aws-sdk (SQS), Redis Streams via Predis/PhpRedis.

Common Misconception

Message brokers and job queues are the same — job queues (Laravel Queue, Symfony Messenger) are application-level abstractions that can use message brokers as a transport.

Why It Matters

Message brokers are the backbone of microservice communication — they enable services to scale independently and survive each other's failures.

Common Mistakes

  • Not acknowledging messages — broker redelivers indefinitely.
  • Ignoring message TTL — queue grows unboundedly on consumer failure.
  • Using message broker where a job queue suffices — adds operational complexity.

Code Examples

✗ Vulnerable
// Synchronous service calls — tight coupling:
$orderService->process($order);
$inventoryService->decrement($items); // Fails? Order partially processed
✓ Fixed
// Async via message broker:
$bus->dispatch(new OrderPlaced($order->id));
// OrderPlacedHandler runs asynchronously, retried on failure
// InventoryHandler subscribes separately, independently retried

Added 23 Mar 2026
Views 27
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 1 ping F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 1 ping F 0 pings S 0 pings S 2 pings M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 1 ping T 1 ping W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T
No pings yet today
No pings yesterday
Perplexity 7 Amazonbot 5 Unknown AI 3 Google 3 SEMrush 2 ChatGPT 1
crawler 18 crawler_json 2 pre-tracking 1
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: High
⚡ Quick Fix
Choose broker based on needs: Kafka for high-throughput replay, RabbitMQ for flexible routing, Redis Streams for lightweight, SQS for managed. Always acknowledge messages.
📦 Applies To
web cli queue-worker Symfony Messenger Laravel Queue
🔗 Prerequisites
🔍 Detection Hints
Auto-detectable: ✗ No
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: High Context: File

✓ schema.org compliant