Currently I have setup ripple mainnet server and provide availability of XRP trading, If any user submits the transaction in his account from the external wallet, How I know which transaction performed? Currently, I have used WebSocket socket and subscribe all account to the listener, So when any transaction comes in subscribed account then it will catch the transaction. But the issue is that when my xrp server is down or listeners missed any transaction then how we fetch incoming transaction later.
Probably the best way is to keep track of the last ledger index you have processed. So when you process all the transactions from ledger 30,000,000, track that you next need to process ledger 30,000,001. If you rejoin the network at ledger 30,000,500, you know that you need to query ledgers 30,000,001 through 30,000,500 before you are synced back up and can continue to process live ledgers.
Though not quite as good, you can be a bit lazier and just keep track of which transaction you saw last. This does require you to use the
account_tx command (or similar) to query. If you see two or more transactions and the first one is the one you last processed, the server should guarantee that there are no gaps.