Skip to content

tosinshada/auction-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Auction Service with Aeron Cluster and Artio/FIXP

A minimal auction service demonstrating:

  • Aeron Cluster for fault-tolerant, replicated state management
  • Artio with iLink3/FIXP for high-performance FIX protocol connectivity
  • SBE (Simple Binary Encoding) for efficient message serialization

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Cluster Client                            │
│              (AuctionClusterClient)                          │
│              - Direct SBE message submission                 │
└───────────────────────────┬─────────────────────────────────┘
                            │ Aeron UDP
                            ▼
┌─────────────────────────────────────────────────────────────┐
│                 Aeron Cluster (Single Node)                  │
│  ┌─────────────────────────────────────────────────────┐    │
│  │               AuctionClusteredService                │    │
│  │  - Handles PlaceOrder/CancelOrder messages           │    │
│  │  - Maintains deterministic AuctionState              │    │
│  │  - Matches orders and broadcasts results             │    │
│  │  - Supports snapshotting for recovery                │    │
│  └─────────────────────────────────────────────────────┘    │
└─────────────────────────────▲───────────────────────────────┘
                              │ Aeron UDP
                              │
┌─────────────────────────────┴───────────────────────────────┐
│                    iLink3 Gateway                            │
│              (ILink3Gateway + ClusterGatewayAdapter)         │
│  - Accepts iLink3/FIXP connections from clients              │
│  - Translates FIX NewOrderSingle ↔ SBE PlaceOrder            │
│  - Bridges external FIXP clients to cluster                  │
└───────────────────────────▲─────────────────────────────────┘
                            │ iLink3/FIXP
                            │
┌─────────────────────────────────────────────────────────────┐
│                  iLink3 Test Client                          │
│              (ILink3TestClient)                              │
│  - Connects via Artio iLink3 initiator                       │
│  - Sends FIX NewOrderSingle messages                         │
│  - Demonstrates end-to-end FIXP integration                  │
└─────────────────────────────────────────────────────────────┘

Project Structure

aeron-test/
├── build.gradle                    # Gradle build with dependencies
├── src/main/
│   ├── java/com/example/auction/
│   │   ├── cluster/
│   │   │   ├── AuctionClusterNode.java       # Single-node cluster launcher
│   │   │   └── AuctionClusteredService.java  # ClusteredService implementation
│   │   ├── gateway/
│   │   │   ├── ClusterGatewayAdapter.java    # Cluster client for gateway
│   │   │   ├── ILink3Gateway.java            # iLink3/FIXP acceptor bridge
│   │   │   └── ILink3TestClient.java         # iLink3 test client (initiator)
│   │   ├── state/
│   │   │   ├── AuctionState.java             # Deterministic order book
│   │   │   └── Order.java                    # Order entity
│   │   ├── client/
│   │   │   └── AuctionClusterClient.java     # Direct cluster test client
│   │   └── messages/                         # (Generated) SBE codecs
│   └── resources/
│       ├── sbe/
│       │   └── auction-messages.xml          # SBE message schema
│       ├── ilink3/
│       │   └── ilink3-schema.xml             # iLink3 message definitions
│       └── logback.xml

Prerequisites

  • Java 21+
  • Gradle 8+

Building

# Generate SBE codecs and compile
./gradlew build

This will:

  1. Generate SBE encoder/decoder classes from auction-messages.xml
  2. Compile all Java sources
  3. Run tests

Running

1. Start the Cluster Node

In one terminal:

./gradlew run -PmainClass=com.example.auction.cluster.AuctionClusterNode

This starts the single-node Aeron Cluster with the AuctionClusteredService.

2. Run the Cluster Client

In another terminal:

./gradlew run -PmainClass=com.example.auction.client.AuctionClusterClient

This runs AuctionClusterClient which:

  • Connects to the cluster
  • Places buy and sell orders
  • Demonstrates order matching
  • Shows cancel functionality

3. Run the iLink3 Gateway

In a third terminal:

./gradlew run -PmainClass=com.example.auction.gateway.ILink3Gateway

The gateway:

  • Connects to the cluster as a client
  • Accepts iLink3/FIXP connections from external clients
  • Translates between iLink3 messages and cluster SBE messages
  • Demonstrates FIX protocol integration

4. Run the iLink3 Test Client

In a fourth terminal:

./gradlew run -PmainClass=com.example.auction.gateway.ILink3TestClient

This test client:

  • Connects to the iLink3 gateway using the FIXP protocol
  • Sends NewOrderSingle messages via iLink3
  • Demonstrates end-to-end flow: iLink3 → Gateway → Cluster

SBE Messages

Message ID Direction Description
PlaceOrder 1 Client → Cluster Submit a buy/sell order
CancelOrder 2 Client → Cluster Cancel an existing order
OrderResponse 3 Cluster → Client Ack/reject/fill notification
AuctionResult 4 Cluster → Clients Broadcast when orders match

Key Concepts

Deterministic State

The AuctionState class maintains order book state deterministically:

  • Uses TreeMap for predictable iteration order
  • All time-based decisions use cluster-provided timestamps
  • No external I/O or random operations

Cluster Snapshotting

AuctionClusteredService implements:

  • onTakeSnapshot() - Serializes all orders to the snapshot
  • Snapshot loading in onStart() - Restores state on recovery

Order Matching

Simple price-time priority matching:

  • Buy orders sorted by price descending (best bid first)
  • Sell orders sorted by price ascending (best offer first)
  • Match occurs when best bid ≥ best offer
  • Match price is midpoint of crossing prices

Configuration

Cluster endpoints (in AuctionClusterNode.java):

  • Ingress: localhost:20110
  • Egress: localhost:20220

iLink3 Gateway (in ILink3Gateway.java):

  • FIXP acceptor: localhost:9880
  • Session ID: TESTSESS
  • Firm ID: TESTFIRM

Notes on iLink3

This implementation demonstrates:

  • iLink3 Gateway acting as an acceptor for external FIXP clients
  • iLink3 Test Client using Artio's initiator to connect via FIXP
  • Translation between FIX NewOrderSingle (tag 35=D) and cluster SBE PlaceOrder messages
  • Session management with Establish/Terminate sequences

The ILink3Gateway shows how to bridge FIX protocol clients to the Aeron Cluster using Artio's iLink3 support, providing a practical example of integrating traditional FIX-based systems with modern low-latency infrastructure.

Cleanup

# Remove cluster data
rm -rf aeron-cluster/ artio-logs/

Dependencies

  • io.aeron:aeron-all - Aeron transport and cluster
  • uk.co.real-logic:artio-* - Artio FIX/FIXP engine
  • uk.co.real-logic:sbe-tool - SBE code generator
  • org.agrona:agrona - High-performance data structures

About

A simple auction service built with Aeron Cluster and Artio

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages