Broker Order API Goes Live: Kafka and RabbitMQ Power Real-Time Trade Execution in New Trading System

From Jeribah, the free encyclopedia of technology

Breaking: Broker Order API Launches as Central Orchestrator for Trading Operations

A new Broker Order API is now operational, serving as the critical orchestration layer that connects asset validation, wallet management, a matching engine, and event streaming in a live trading ecosystem. The system uses Kafka and RabbitMQ to process and communicate order lifecycle events, from user intent to final confirmation.

Broker Order API Goes Live: Kafka and RabbitMQ Power Real-Time Trade Execution in New Trading System
Source: dev.to

Developed as part of the My Broker B3 project, this API acts as the single entry point for all buy and sell orders. It coordinates with four downstream services: Asset API (REST/Feign), Wallet API (REST/Feign), B3 Matching Engine (via RabbitMQ), and Broker Wallet (via Kafka).

How the Order Flow Works

When a user submits a POST request to /api/v1/orders with order details—including userId, ticker, quantity, price, and side (BUY or SELL)—the API immediately begins a multi-step validation and routing process.

First, it calls the Asset API via Feign to verify the ticker exists and is active. Then it checks the Wallet API to confirm sufficient balance. After persisting the order in MySQL with PENDING status, it sends the order to the B3 Matching Engine via RabbitMQ and publishes a PENDING event to Kafka for the entire ecosystem.

Real-Time Status Updates

Once the matching engine processes the order, it returns the result through RabbitMQ. The Broker Order API updates the order status in MySQL to FILLED or REJECTED and publishes a final status event on Kafka. The Broker Wallet consumes these events to block, settle, or revert funds accordingly.

“This two-message channel design ensures both low-latency execution tracing and broad ecosystem notification,” explains a lead engineer on the project. “The Kafka events allow multiple downstream services to react independently without overloading the matching engine.”

Technology Stack Behind the Orchestration

The service runs on Java 21 with Spring Boot 3.3.5, using MySQL for order persistence and Flyway for database migrations. Spring Kafka handles lifecycle event publication, while Spring AMQP (RabbitMQ) integrates with the matching engine. REST calls to Asset and Wallet APIs leverage Spring Cloud OpenFeign.

Broker Order API Goes Live: Kafka and RabbitMQ Power Real-Time Trade Execution in New Trading System
Source: dev.to

Background: The Ecosystem of Financial Microservices

The Broker Order API is the final piece in a larger microservice architecture. The ecosystem previously included a price synchronizer, a matching engine, a financial custody service, and an asset catalog. Each component was built separately, but the Broker Order API now connects them all.

“This API is the maestro of the ecosystem,” the engineer adds. “Where the user intends to trade, and where the results land.” The system uses different communication channels for different purposes: synchronous REST for validation, asynchronous RabbitMQ for order execution, and Kafka for event streaming.

What This Means for Trading Infrastructure

With the Broker Order API live, the entire order lifecycle is now fully automated and visible. The separation of concerns—with distinct services for validation, matching, and wallet management—allows each component to scale independently.

Future consumers can subscribe to the Kafka topic order-events-v1 to react to status changes without modifying the core API. The architecture also supports different reliability levels: RabbitMQ ensures reliable delivery to the matching engine, while Kafka enables replay and multiple consumers.

Next Steps: Expanding the Ecosystem

The team plans to add more consumers to the Kafka event stream, such as notification services and audit logging. Additional performance optimizations for high-throughput scenarios are also under consideration.

“We now have a scalable, resilient foundation for order execution,” the engineer concludes. “The Broker Order API is the backbone that keeps the entire trading ecosystem in sync.”