문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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.

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