Is it possible to disconnect an Acceptor session in QuickFIX/J ? I have tried the method disconnect(String reason, boolean logError)
. But once the counterparty tried to reconnect then the session is reconnected.
What i want is to stay disconnected.
According to the javadoc comment for the disconnect()
method you should rather not call it from user code:
* This method should not be called from user-code since it is likely
* to deadlock when called from a different thread than the Session thread
* and messages are sent/received concurrently.
* Instead the logout() method should be used where possible.
So please use the logout()
method to log out from a Session. It will also disable the Session in a way that counterparties will be logged out when connecting. But there can be a short timeframe when they will be logged on. This is because that flag is only checked once a second.
To reject a Logon right away, you could throw a RejectLogon
Exception out of your fromAdmin()
callback.
I am expecting a mechanism to manually logout and stay logged out (in other words stay disconnected) until manually allow to logon. But, when I try the logout() method, if the counter party tries to logon then system allowing it. I tried to set a RejectReason while I'm manually logout() in order to throw RejectLogon as you mentioned, this message was not available when the Logon request received. So, I cannot maintain the session logged out.
To throw
RejectLogon
you need to really throwRejectLogon
out offromAdmin()
as I mentioned. It won't work to throw it fromlogout()
. So first calllogout()
, then put a check into yourfromAdmin()
to throwRejectLogon
when aLogon
comes in. That will reject incomingLogons
.Before i throw the
RejectLogon
fromfromAdmin
, i want to make sure this logout is imposed manually. So, i would like to validate theLogoutReason
for the corresponding session'sstate
. But, it is getting nullified before it reach to the methodfromAdmin()
. Any idea to handle this situation?You mean you only want to throw
RejectLogon
if you formerly decided to logout manually? Can't you store a boolean flag somewhere in your application? And then simply check if that boolean flag has been set totrue
? Or did I misunderstand you?We can go for the boolean flag suggestion @ChristophJohn. Thanks a lot for the suggestion.