<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">This looks like a reasonable and good suggestion.</div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">I created issue 987 for it: <a href="https://github.com/connamara/quickfixn/issues/987">https://github.com/connamara/quickfixn/issues/987</a></div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">I hope to take a deeper look within the next month or 2.</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Oct 30, 2025 at 5:02 AM Andreas Meisner via Quickfixn <<a href="mailto:quickfixn@lists.quickfixn.com">quickfixn@lists.quickfixn.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi @all,<br>
<br>
this is my first email on this list and I am not yet familiar with the <br>
rules here.<br>
<br>
I have found the following issue, because I have implemented a <br>
IMessageStore for MSSQL server (using EF) having indices on the database <br>
tables:<br>
<br>
In class Session we have the method Persist(Message, string):<br>
<br>
         protected void Persist(Message message, string messageString)<br>
         {<br>
             if (PersistMessages)<br>
             {<br>
                 SeqNumType msgSeqNum = <br>
message.Header.GetULong(Fields.Tags.MsgSeqNum);<br>
                 _state.Set(msgSeqNum, messageString);<br>
             }<br>
             _state.IncrNextSenderMsgSeqNum();<br>
         }<br>
<br>
The call of Set() and IncrNextSenderMsgSeqNum() should be in one <br>
transaction, but currently I have a straight forward implementation with <br>
no dependencies between these methods. In my case a call to Set() was <br>
successful, but the call to IncrNextSenderMsgSeqNum() failed, leaving <br>
the database in an inconsitant state. I think the same could happen when <br>
using FileStore, but here we do not have an index that could cause an <br>
exception.<br>
<br>
I can catch this in my DbMessageStore implementation, but it would be <br>
nicer to have only one method in this case.<br>
<br>
So my proposal for a change is:<br>
<br>
<br>
1. Add a new method in interface IMessageStore with a default <br>
implementation:<br>
<br>
public interface IMessageStore : IDisposable<br>
{<br>
<br>
     // ... existing members<br>
<br>
     public bool SetAndIncrNextSenderMsgSeqNum(SeqNumType msgSeqNum, <br>
string msg)<br>
     {<br>
         bool result = Set(msgSeqNum, msg);<br>
         IncrNextSenderMsgSeqNum();<br>
         return result;<br>
     }<br>
}<br>
<br>
2. Add the method with the same signature to class SessionState:<br>
<br>
         public bool SetAndIncrNextSenderMsgSeqNum(SeqNumType msgSeqNum, <br>
string msg)<br>
         {<br>
             lock (_sync) { return <br>
MessageStore.SetAndIncrNextSenderMsgSeqNum(msgSeqNum, msg); }<br>
         }<br>
<br>
3. Call the new method in class Session:<br>
<br>
         protected void Persist(Message message, string messageString)<br>
         {<br>
             if (PersistMessages)<br>
             {<br>
                 SeqNumType msgSeqNum = <br>
message.Header.GetULong(Fields.Tags.MsgSeqNum);<br>
                 _state.SetAndIncrNextSenderMsgSeqNum(msgSeqNum, <br>
messageString);<br>
             }<br>
             else<br>
             {<br>
                 _state.IncrNextSenderMsgSeqNum();<br>
             }<br>
         }<br>
<br>
This change should be 99.9% backwards compatible and should not affect <br>
any existing implementation. The only difference (the 0.1%) is that the <br>
call to Set() and IncrNextSenderMsgSeqNum() is in one lock(_sync) in <br>
class SessionState, but this should be also an improvement.<br>
<br>
Please let me know, if I can add a new pull request with these changes.<br>
<br>
<br>
Thanks,<br>
Andreas<br>
<br>
<br>
-- <br>
Andreas Meisner<br>
Software-Development<br>
<br>
C/Poeto Alonso Quesada 30<br>
35310 Santa Brígida<br>
Las Palmas Gran Canaria<br>
Spain<br>
<br>
Tel. +49 176 42026763<br>
Email: <a href="mailto:software@meisner.de" target="_blank">software@meisner.de</a><br>
Web: <a href="http://software.meisner.de" rel="noreferrer" target="_blank">http://software.meisner.de</a><br>
<br>
N.I.E. Y-9624964-F<br>
<br>
_______________________________________________<br>
Quickfixn mailing list<br>
<a href="mailto:Quickfixn@lists.quickfixn.com" target="_blank">Quickfixn@lists.quickfixn.com</a><br>
<a href="http://lists.quickfixn.com/listinfo.cgi/quickfixn-quickfixn.com" rel="noreferrer" target="_blank">http://lists.quickfixn.com/listinfo.cgi/quickfixn-quickfixn.com</a><br>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span><div dir="ltr" style="margin-left:0pt" align="left"><table style="border:none;border-collapse:collapse"><colgroup><col width="122"><col width="298"></colgroup><tbody><tr style="height:84.75pt"><td style="vertical-align:top;overflow:hidden"><span style="border:none;display:inline-block;overflow:hidden;width:105px;height:83px"><a href="https://www.connamara.com" target="_blank"><img src="https://lh4.googleusercontent.com/1ZKItKWIoLUepUXvEXgEeZWBlntjas7UxLPLuLLnsApbxAcRepKELA_SwZBe1BWEZ3huC6sJdz2ZzvUYLNgu56Zcm8bo2R_iLzXZVjDmMo67675iop6mEMOg_Y6q8Mtz7ylOW9t8RazXt-tyJtEyhE0" width="105" height="83" style="margin-left: 0px; margin-top: 0px;"></a></span></td><td style="vertical-align:top;padding:5pt;overflow:hidden"><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Archivo,sans-serif;color:rgb(0,65,107);background-color:transparent;vertical-align:baseline">Grant Birchmeier</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Archivo,sans-serif;color:rgb(0,65,107);background-color:transparent;vertical-align:baseline">Director of Engineering, Connamara</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Archivo,sans-serif;color:rgb(0,65,107);background-color:transparent;vertical-align:baseline"><a href="mailto:gbirchmeier@connamara.com" target="_blank">gbirchmeier@connamara.com</a></span></p></td></tr></tbody></table></div></span></div></div></div>

<br>
<span style="color:rgb(29,28,29);font-family:Slack-Lato,appleLogo,sans-serif;white-space:pre-wrap;background-color:white"><font size="2">This email, along with any attachments, is confidential. If you believe you received this message in error, please contact the sender immediately and delete all copies of the message. Thank you from Connamara Systems, LLC.</font></span>