Question

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));
Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top