문제

Is it neccessary to call this line

Session.lookupSession(is).logon();

in this code

socketInitiator.start();
            SessionID sessionId = socketInitiator.getSessions().get(0);
            Session.lookupSession(id).logon();
            while (!Session.lookupSession(id).isLoggedOn()) {
                System.out.println("Waiting for login success");
                Thread.sleep(500);
            }

what is its purpose, as when I omit it, it still gets by the while loop.

EDIT_________________

I was using this in a unit test

socketInitiator.start();
            SessionID sessionId = socketInitiator.getSessions().get(0);
            Session.lookupSession(id).logon();
            while (!Session.lookupSession(id).isLoggedOn()) {
                System.out.println("Waiting for login success");
                Thread.sleep(500);
            }
        System.out.println("Logged In...booking SingleOrder from session: " + sessionId);


        //check that the party receives the fix message
        assertTrue(isBookSingleOrderReceivedFromFixInbound(sessionId));
도움이 되었습니까?

해결책

I have no idea what that function is for, or why it even exists. (I could look it up, sure, but I'm just saying that I've never had to use it.)

The start() call should cause the initiator to start attempting logins (assuming the current time is in the defined session). You shouldn't even have a while loop like this.

You should just call start(), and then do nothing. If logon succeeds, you'll see the FromApp and FromAdmin callbacks start to get triggered for incoming messages (including your logon response).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top