Uploaded image for project: 'QuickFIX/J'
  1. QuickFIX/J
  2. QFJ-797

Add a clean and safe mechanism to disconnect a session from within a call-back

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Default
    • Resolution: Unresolved
    • Affects Version/s: 1.5.3
    • Fix Version/s: None
    • Component/s: Engine
    • Labels:
      None

      Description

      Hi,

      There is currently no clean and safe mechanism to completely stop and disconnect a session from within a call-back (e.g. when processing an incoming message inside fromApp()) with the effect that the session is immediately disconnected, no reject messages are sent back to the counter-party and no change to the session store is made.

      Such a mechanism is useful for implementing failure handling scenarios, e.g. when a target database becomes suddenly unavailable, or the application needs to be shutdown in emergency. In such cases it's best to close the TCP socket immediately and keep the session state unchanged.

      One could try to use something like SocketInitiatior.stop(true), but it's not generic (does not work for acceptors) and it results in a call to Session.disconnect(). Then, if Session.disconnect() is called from fromApp(), we get an immediate call to the onLogout() callback - a call is made from within the fromApp() call-back into the onLogout() call-back. This isn't a particularly safe scenario, especially when in most cases the onLogout() call is made by from QuickFIX/J threads.

      Another solution is to throw a RuntimeException within the call-back method, but it's not reliable right now (QFJ-793, QFJ-795) and makes QuickFIX/J send an error message and the stack trace into the log.

      I propose to add a special a subclass of RuntimeException, e.g. DisconnectSessionExcepion, which when thrown from a call-back method would notify QuickFIX/J that the session should be disconnected immediately. In such case only an informational message would be send to the log instead of error with a stack trace.

      Regards,
      Andrzej Hajderek

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              andrzej_ls Andrzej Hajderek
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: