Nyger
Nyger

Reputation: 215

quickfix event after sending message

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?

Upvotes: 0

Views: 1039

Answers (4)

Gus
Gus

Reputation: 1

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);
    }
}

Upvotes: 0

Frank Smith
Frank Smith

Reputation: 988

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.

Upvotes: 0

Grant Birchmeier
Grant Birchmeier

Reputation: 18504

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

Upvotes: 1

robthewolf
robthewolf

Reputation: 7624

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

Upvotes: 0

Related Questions