0

I am doing something with fix protocol using quickfix library.

I wrote class like this:

public class ApplicationImpl implements Application {
...
    @Override
public void toApp(Message arg0, SessionID arg1) throws DoNotSend {
    //this is invoked before sending message
}
...
}

I wonder how to invoke some method after sending message?

Nyger
  • 215
  • 1
  • 2
  • 7

4 Answers4

1

QuickFIX does not offer a after-message-send callback.

Grant Birchmeier
  • 17,809
  • 11
  • 63
  • 98
0

You need to have this somewhere in your code to send a message (not in the overriden methods):

Session.sendToTarget(outgoingMessage, orderSession);

That will execute some internal quickfixJ code and then call toApp(). The toApp() method allows you do modify the message before it is sent to the broker. But ideally in order to do something after you send you just need to add code after the call to Session.sendToTarget().

robthewolf
  • 7,343
  • 3
  • 29
  • 29
  • Yeah I know how to send message but I looking for class which provides callback after sending messages to Server. Code after Session.sendToTarget() may by execute before actually sending message. – Nyger Oct 07 '13 at 13:25
  • I don't think so, the pretty sure sendToTarget doesn't invoke a new thread. But additionally what difference does it make at that point? – robthewolf Oct 07 '13 at 13:33
  • In method toAdmin I intercept sending Heartbit and then I send some message. Unfortunately in logs (provides from ScreenLogFactory) my message appear before Heartbit. – Nyger Oct 07 '13 at 13:42
  • I don't understand your last comment perhaps you could supply some more code to help explain your problem and what you want – robthewolf Oct 07 '13 at 14:15
0

If you are adventurous, you can modify QuickFIX/J to do it. The MINA network layer does provide a messageSent callback. If you override that method in QFJ's InitiatorIoHandler (or AcceptorIoHandler) you could either directly process the messageSent event or propagate it to a modified Application interface.

Frank Smith
  • 978
  • 5
  • 11
0

If I undertand correctly. You need to do some action after you send a message. If it is correct I have the following example:

public static void send(Message message) {
        boolean sent = Session.sendToTarget(message, mySessionId);
        if (sent){
            //do something
        }else {
            //something else
        }
        System.out.println("El mensaje se mandó: " + sent);
    } catch (SessionNotFound e) {
        System.out.println(e);
    }
}
Gus
  • 1
  • 2