Repository navigation
Conversation
Before this change, some messages were lost. This happened when the app sent a message while the session was not logged on, for example outside the session time. The message was saved in the store, and then the scheduled reset deleted it. With KeepUnsentMessagesOnReset=Y, the message store keeps the sequence number of the first message that was not sent. When the session is reset by its schedule, the unsent application messages are copied to the new store with new sequence numbers. After the next logon, they are sent again when the counterparty asks for them. The value is saved in the store, so it works after a restart. It is supported by MemoryStore, FileStore and CachedFileStore. The default is N. So the reset works the same as before. Refs quickfix-j#463, quickfix-j#986
JdbcStore can now keep the first unsent sequence number. The value is saved in a new table, "unsent_seqnums". The name can be changed with JdbcStoreUnsentSeqNumsTableName. The table is optional. Without it, JdbcStore works as before and KeepUnsentMessagesOnReset has no effect. The SQL scripts for HSQLDB, MySQL, MSSQL, Oracle and PostgreSQL create the new table. Refs quickfix-j#463, quickfix-j#986
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1345 +/- ##
============================================
+ Coverage 70.79% 71.20% +0.41%
- Complexity 2270 2324 +54
============================================
Files 161 162 +1
Lines 9077 9231 +154
Branches 1192 1213 +21
============================================
+ Hits 6426 6573 +147
- Misses 2198 2204 +6
- Partials 453 454 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add tests for several unsent messages, a scheduled reset without unsent messages, the warnings when the setting has no effect, and the update and custom table name in JdbcStore.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the app sends a message while the session is not logged on (for example outside the session time), the message is saved in the message store. Then the session is reset by its schedule, and the reset deletes the store. So the message is never sent.
This does not match the Javadoc of
Application.onCreate(): "If no one is logged on, the messages will be sent at the time a connection is established with the counterparty."Closes #986
Refs #463
Solution
This PR adds a new session setting:
KeepUnsentMessagesOnReset(defaultN).With
KeepUnsentMessagesOnReset=Y:PossDupFlag=Ywhen the counterparty asks for them (ResendRequest).The value is saved in the store, so it works after a restart.
As discussed in #986:
MessageStorehas two newdefaultmethods:getFirstUnsentSenderMsgSeqNum()andsetFirstUnsentSenderMsgSeqNum(int). By default they do nothing (get returns-1), so custom stores still compile and work as before.MemoryStore: in memory.FileStoreandCachedFileStore: new file<session>.firstunsentseqnum.JdbcStore: new tableunsent_seqnums. The name can be changed withJdbcStoreUnsentSeqNumsTableName. The table is optional. Without it,JdbcStoreworks as before.If the store does not support it, or if
PersistMessages=N, the session logs a warning and works as before.Messages are still lost with
ResetOnLogon,ResetOnLogout,ResetOnDisconnect, a Logon withResetSeqNumFlag=Y, or a call toSession.reset(). These resets are asked by the user or by the counterparty, so this PR does not change them.Open question
The default is
N, so nothing changes for current users. In #986 we did not decide if it should beYby default. I am happy to change it.Tests
SessionTest: unsent messages are kept after a scheduled reset, resent after logon, and kept after a restart; messages that were already sent are not kept; no change when the setting is off.DefaultSessionFactoryTest: the new setting is read.AbstractMessageStoreTest: get, set, refresh and reset of the new value. It runs forMemoryStore,FileStore,CachedFileStoreandJdbcStore(also the legacy table layout).JdbcStoreTest:JdbcStoreworks without the new table.