Staffix¶
Streaming API for FIX: a FIX engine for Java that treats latency as a correctness property.
Staffix is a full FIX protocol implementation for Java 11 and up: session layer, type-safe message encoders for FIX 4.2, 4.3, 4.4, 5.0, 5.0 SP1, 5.0 SP2 and FIX Latest, persistence, logging, monitoring and administration. It is an ordinary library: it runs in your process and on your threads, with nothing else to deploy or operate.
- 19.5 µs round trip, against QuickFIX/J's 37.1 on identical settings, and 11.2 µs busy-spinning
- Under one byte allocated per message, against QuickFIX/J's sixteen kilobytes
See Performance for the full measurements and how they are reached, and Compared to other FIX engines for QuickFIX/J and Artio.
What you get¶
- Protocol: FIX 4.2, 4.3, 4.4, 5.0, 5.0 SP1, 5.0 SP2 and FIX Latest, and the FIXT.1.1 session layer, with type-safe generated encoders.
- Session layer: initiator and acceptor, resend handling, gap fill, heartbeats, cancel-on-disconnect.
- Persistence and logging: in memory, file, JDBC, SLF4J and OTLP, each optionally behind an off-heap async handoff that keeps the I/O off the session thread.
- Configuration: in memory, YAML files or a database table, with a JSON schema your editor validates against.
- Administration: logon, logout, sequence resets, sending messages, adding, editing and removing sessions, settings reload and switching to a backup, exposed through an SPI, JMX and HTTP impls; see Runtime administration.
- Alerting: probes on session health and your own conditions, published through an SPI, with SLF4J and Prometheus Alertmanager implementations; see Alerting.
- Monitoring: Micrometer metrics, OpenTelemetry tracing and Grafana dashboards.
- Extension points: SPIs for stores, loggers, settings stores, admin exporters, alerts publishers and session plugins.
- Integration: a plain application factory or a Spring Boot starter.
- Runtime: Java 11 source and target, running on JDK 11 through 25.
High availability¶
Two engines run the same sessions: one leads, the other follows and takes over when the leader fails, so the counterparty only sees a disconnection. See High availability.
- Leader election: built on primos, the election half of Raft, with a witness as third voter; or plug in a primos node your application already runs.
- Store replication over TCP, chosen per session:
NONE,ASYNC, orSYNC_RECEIVEDandSYNC_APPLIED, where the counterparty never receives a message the follower does not have. - Catch-up: a follower that connects late or loses the stream resumes where it left off, or receives a snapshot of each session without stalling the others.
- Failover: the new leader resumes the sessions at the old leader's sequence numbers, moving them ahead when it may have missed messages the old leader sent.
- Fencing against split brain: a leader cut off from the majority drops its sessions before another node can be elected, so the two nodes never run a session at the same time.
- Planned operations: switchover with an orderly Logout and no sequence gap, maintenance mode and re-sync, through the admin API over HTTP and JMX.
- Session settings replication: sessions added, changed or removed at runtime on the leader reach the follower, and settings that differ between the nodes are reported.
- Observability:
ha.*meters, alerting probes and a status endpoint showing who leads and how far behind the follower is.
Admin console¶
staffix-admin is a web console for staffix engines. It shows every session of every engine at a glance, controls them (logon, logout, sequence numbers, switching to a backup), edits their settings, sends messages, and reads their availability, metrics and FIX logs from your Prometheus, Loki, Elasticsearch or ClickHouse backends. Logged messages are decoded with the remote session's own dictionary, and an order can be traced across sessions and engines.
Why another FIX engine¶
The FIX engine is not a peripheral. It is the first thing every tick touches on the way in and the last thing every order touches on the way out: it sits inside your tick-to-trade twice, and there is no path around it.
You can spend months tuning a trading system: lock-free structures, allocation-free hot paths, GC pauses hunted down, threads pinned to cores. Then you put a FIX engine built without latency in mind at the boundary, and every message goes through something that allocates kilobytes and adds tens of microseconds per round trip, its garbage landing in the heap you tuned. A low-latency system with a high-latency FIX engine at its edge is not a low-latency system.
Open source Java has two production-grade FIX engines, QuickFIX/J and Artio, and each makes you give up something. QuickFIX/J is a library, but it is not low latency: it was designed when a millisecond was a small number, and no tuning removes its garbage. Artio is low latency, but it is not a library: it runs on Aeron, which brings a media driver, an archive and log directories to operate beside your application. Both are good at what they were built for; see Compared to other FIX engines for the evidence.
That is one gap; the other opens the day you go live. Neither engine goes much beyond the protocol: QuickFIX/J stops at JMX beans and Artio at an engine API and Aeron counters, so the metrics, alerts and runtime administration a production desk relies on are yours to build and wire in.
Staffix closes both gaps: a true low-latency FIX engine that is an ordinary Java library, ready to operate. It does not allocate while parsing or encoding a message, and every optional check is off by default, costs nothing until you turn it on, and documents what turning it on costs. Metrics, tracing, alerting and an admin API come with it, each pluggable and kept off the message path.
Getting started¶
Staffix is published on Maven Central under the
org.lolaf.staffix group id. The examples below run from a clone, built once with mvn clean install at the
repository root.
The quickest look at a working session is the quickstart: an acceptor and an initiator in one process, a QuoteRequest sent and a Quote returned:
mvn compile exec:java -pl examples/quickstart \
-Dexec.mainClass=org.lolaf.staffix.examples.quickstart.QuickstartExample
QuickstartExample is
the whole of what a first Staffix program needs, with nothing hidden in a base class. The other worked examples are
indexed in examples/: a session plugin adding a field the application never wrote, a trading
example, a market data streamer, a quote request client, YAML session settings, a Spring Boot application, and one wired
up with full monitoring.
In your own project¶
The dependencies for a first application are the engine and an implementation of each pluggable part:
<dependency>
<groupId>org.lolaf.staffix</groupId>
<artifactId>staffix-impl</artifactId>
<version>${staffix.version}</version>
</dependency>
<dependency>
<groupId>org.lolaf.staffix</groupId>
<artifactId>staffix-application-factory-simple</artifactId>
<version>${staffix.version}</version>
</dependency>
<dependency>
<groupId>org.lolaf.staffix</groupId>
<artifactId>staffix-messages-store-memory-impl</artifactId>
<version>${staffix.version}</version>
</dependency>
<dependency>
<groupId>org.lolaf.staffix</groupId>
<artifactId>staffix-sessions-settings-store-memory-impl</artifactId>
<version>${staffix.version}</version>
</dependency>
<dependency>
<groupId>org.lolaf.staffix</groupId>
<artifactId>staffix-messages-logger-slf4j-impl</artifactId>
<version>${staffix.version}</version>
</dependency>
The encoders for the FIX version you speak are generated into your build, from the dictionary the matching
staffix-fix-* artifact carries:
<plugin>
<groupId>org.lolaf.staffix</groupId>
<artifactId>staffix-fix-encoders-generator-maven-plugin</artifactId>
<version>${staffix.version}</version>
<configuration>
<dictionaryFile>classpath:FIX44.xml</dictionaryFile>
<sourcesOutputDirectory>${project.build.directory}/generated-sources/fix</sourcesOutputDirectory>
<packageName>org.lolaf.staffix.fix44</packageName>
</configuration>
<executions>
<execution>
<goals>
<goal>code-generator</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.lolaf.staffix</groupId>
<artifactId>staffix-fix-44</artifactId>
<version>${staffix.version}</version>
</dependency>
</dependencies>
</plugin>
FIX versions and dictionaries lists the versions and explains the options.
Then build an engine, hand it an application per session, and start an acceptor or an initiator from it.
QuickstartExample
is that program, and it is the one the command above runs.
AI agentic coding ready¶
Staffix is AI ready: its Claude Code plugin creates a new application, changes the components of an existing one, and migrates a QuickFIX/J application, each proven by a test it runs. It works from the documentation and a catalogue of every component, at your staffix version.
Install the Claude Staffix plugin using Lolaf market place at https://www.lolaf.org/claude/marketplace.json
Documentation¶
Everything else is in the documentation.
Is it production ready?¶
Not yet proven in production: no one runs it on a live trading session today. Every build runs the engine's own suite, 22 of the official FIX session conformance scenarios, and a real QuickFIX/J engine driven against Staffix in both roles; a soak test trades Staffix against QuickFIX/J continuously over a real network. The API is settled, and any breaking change is listed in the changelog.
Support is community only, on a best-effort basis: issues are read and answered, with no guaranteed response time.
Licence¶
Apache License 2.0.