0

I wrote an QuickFix program and created a config file.. Now, when I'm running my application, nothing happens.. So I ask me, how I can recognize if the connection (my program is of type initiator) is established or not.

I've added to the methods that I implement from the Application interface

void fromAdmin(Message message, SessionID sessionId)
void fromApp(Message message, SessionID sessionId)
void onCreate(SessionID sessionId)
void onLogon(SessionID sessionId)
void onLogout(SessionID sessionId)
void toAdmin(Message message, SessionID sessionId)
void toApp(Message message, SessionID sessionId)

a System.out and a logger.info, but nothing of them fires something.

If a connection established, the methods onCreate and onLogon are invoked, or?! So the System.outs in these methods should write something..

But are there any other opportunitys to check wheter the connection established, respectively the config file is valid.

P.S.: I use the SessionSettings to read the config File in.. But I can't find a method in the SessionSettings like validateConfigFile() or something like that.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
mrbela
  • 4,477
  • 9
  • 44
  • 79
  • What is your application ? `initiator` or `acceptor`. You want both of them to see or test anything. – DumbCoder Apr 17 '15 at 09:33
  • Hey! My application is an initiator. What do you mean with "You want both of them to see or test anything"? I have only an initiator and want to test the connection. – mrbela Apr 17 '15 at 10:08
  • What/whom are you trying to connect to ? – DumbCoder Apr 17 '15 at 10:16
  • With an german exchange.. Am I right with my assumption that when the methods onCreate and onLogon doens't print something to the command line, then the configuration is wrong? Btw: I don't get a ConfigError. – mrbela Apr 17 '15 at 10:39
  • Did you try debugging ? That is the best option to figure out. Asking somebody else to guess isn't going to help much. There might be something wrong much before that also. – DumbCoder Apr 17 '15 at 10:59
  • What should I debug? My Java program does not throw any exceptions.. It finds the config file and reads it in.. Then it goes in a while-loop and is waiting for Fix messages.. But it should invoke the two methods?! Nothing of this happen.. – mrbela Apr 17 '15 at 11:09
  • Messages don't flow until session has been set up and logon has happened. Check that while debugging. – DumbCoder Apr 17 '15 at 11:37
  • Yes, I know.. I only see that the both methods (onCreate, onLogon) aren't invoked by the program, but the program reads the configuration file in withouth an error! So I wanted to ask, if there are any other opportunities to know what went wrong? – mrbela Apr 17 '15 at 12:32

2 Answers2

0

Has your config file got FileLogPath=log?

Then to debug you look at the FIX messages log, usually in the bin/debug/log directory, which is where it would be for the above config file. If it's not a security risk then paste your config file here please. Also, yes add the System.Out to your Application interface. Here's mine:

public void FromApp(Message msg, SessionID s)
    {
        Console.WriteLine("IN: " + msg.ToString());
desertnaut
  • 57,590
  • 26
  • 140
  • 166
rupweb
  • 3,052
  • 1
  • 30
  • 57
0

You can download Banzai application which is an accpetor/iniciator with grafic interface. You can iniciate a session, and send/receive messages from your app.

Main class you need in your Iniciator

    public class Banzai {
    private static final CountDownLatch shutdownLatch = new CountDownLatch(1);

    /** enable logging for this class */
    private static Logger log = LoggerFactory.getLogger(Banzai.class);
    private static Banzai banzai;
    private boolean initiatorStarted = false;
    private Initiator initiator = null;
    private JFrame frame = null;

    public Banzai(String[] args) throws Exception {
        InputStream inputStream = null;
        if (args.length == 0) {
            inputStream = new BufferedInputStream(new FileInputStream(new File("config/banzai.cfg")));
        } else if (args.length == 1) {
            inputStream = new FileInputStream(args[0]);
        }
        if (inputStream == null) {
            System.out.println("usage: " + Banzai.class.getName() + " [configFile].");
            return;
        }
        SessionSettings settings = new SessionSettings(inputStream);
        inputStream.close();

        boolean logHeartbeats = Boolean.valueOf(System.getProperty("logHeartbeats", "true")).booleanValue();

        OrderTableModel orderTableModel = new OrderTableModel();
        ExecutionTableModel executionTableModel = new ExecutionTableModel();
        BanzaiApplication application = new BanzaiApplication(orderTableModel, executionTableModel);
        MessageStoreFactory messageStoreFactory = new FileStoreFactory(settings);
        LogFactory logFactory = new ScreenLogFactory(true, true, true, logHeartbeats);
        MessageFactory messageFactory = new DefaultMessageFactory();

        initiator = new SocketInitiator(application, messageStoreFactory, settings, logFactory, messageFactory);

        frame = new BanzaiFrame(orderTableModel, executionTableModel, application);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public synchronized void logon() {
        if (!initiatorStarted) {
            try {
                initiator.start();
                initiatorStarted = true;
            } catch (Exception e) {
                log.error("Logon failed", e);
            }
        } else {
            Iterator<SessionID> sessionIds = initiator.getSessions().iterator();
            while (sessionIds.hasNext()) {
                SessionID sessionId = (SessionID) sessionIds.next();
                Session.lookupSession(sessionId).logon();
            }
        }
    }

    public void logout() {
        Iterator<SessionID> sessionIds = initiator.getSessions().iterator();
        while (sessionIds.hasNext()) {
            SessionID sessionId = (SessionID) sessionIds.next();
            Session.lookupSession(sessionId).logout("user requested");
        }
    }

    public void stop() {
        shutdownLatch.countDown();
    }

    public JFrame getFrame() {
        return frame;
    }

    public static Banzai get() {
        return banzai;
    }

    public static void main(String args[]) throws Exception {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            log.info(e.getMessage(), e);
        }
        banzai = new Banzai(args);
        if (!System.getProperties().containsKey("openfix")) {
            banzai.logon();
        }
        shutdownLatch.await();
    }
}

NOTE: The information in your .settings has to match with the information you have in your code.

After you start both codes you will start to receive logon, and heartbeat messages.

Gus
  • 1
  • 2