Asynchronous File-Based Session Storage writes session state and messages to files using a separate thread for each storage instance. It reduces the file-operation work on the message-processing path. Compare its recovery and replay requirements with the other storage types in Selecting Storage for Session Messages Logging.
Returning from OnixS::FIX::Session::send does not guarantee that asynchronous storage has written the message or updated the state files. If the process stops abruptly, pending writes can be lost. On restart, recovery uses the files that remain; it cannot recover writes that never reached them.
A file write, a buffer flush, and synchronization with the storage device are separate operations. For asynchronous file storage, OnixS::FIX::Session::flushSessionStorage waits for queued operations, writes pending sequence-number updates, and flushes the summary buffer. When syncData is true, it also synchronizes the current summary file with the storage device.
OnixS::FIX::EngineSettings::asyncFileBasedStorageQueueMaxSize limits the outstanding commands for each storage instance, including message writes and sequence-number updates. If the queue exceeds the limit, the submitting thread spin-waits until capacity is available. Sending and incoming-message processing can therefore pause for storage.
If the storage thread stops because of an exception, the Engine reports OnixS::FIX::EngineErrorReason::InternalError through OnixS::FIX::IEngineListener::onError on the storage thread. A later storage operation, including OnixS::FIX::Session::flushSessionStorage, can rethrow the stored exception.
For normal shutdown, use the session and Engine shutdown sequence in Shutting down the whole Application. Do not terminate the process to stop storage writes. For restoration, sequence-number reconciliation, and agreed resets, follow Restoring Session State from Log Files. Availability for replay also depends on logging and resend settings; see Write completion and replay.
To create such a session, set the storageType parameter in the OnixS::FIX::Session::Session constructor to OnixS::FIX::SessionStorageType::AsyncFileBased.