Question

I'm doing something like this in my Quickfix/J Application implementation:

public void toApp(Message message, SessionID sessionID) throws DoNotSend {
    try {
        Session.sendToTarget(message, sessionID);
    } catch (SessionNotFound e) {
        e.printStackTrace();
    }
}

but the code in Session.Java itself calls application.toApp(message, sessionID); in the method

 private boolean sendRaw(Message message, int num) {

what is the correct way to send messages?

Was it helpful?

Solution

The toApp method is a callback function that is called whenever a message is sent to the counterparty. Looking at your code, I feel that your logic is recursive in itself. SendToTarget calls toApp and toApp calls sendToTarget. A simple way to send messages is to use the concrete session object, say mySession. Then you may do mySession.send(Message).

OTHER TIPS

If you are trying to send a message in response to a received message, you'll want to do that in the fromApp callback method instead.

The toApp callback is for outgoing messages. This can be useful if you want to do some extra validation or risk management on outgoing messages. If you don't want to send the message, then throw a DoNotSend exception.

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