quickfix-j / quickfixj

QuickFIX/J is a full featured messaging engine for the FIX protocol. - This is the official project repository.
http://www.quickfixj.org
Other
957 stars 611 forks source link

(Almost) Everything use StringField before sending #633

Closed orbli closed 1 year ago

orbli commented 1 year ago

Describe the bug I cannot parse message locally for a pre-flight check.

For example, ((FieldMap) targetFieldMap).setChar((int) key, (char) value) do not insert a character (but instead a StringField: https://github.com/quickfix-j/quickfixj/blob/f4920953377e630323cbc5bd91f5008747cf435c/quickfixj-core/src/main/java/quickfix/FieldMap.java#L170 )

To Reproduce Above description should be very sufficient. To elaborate more, something like

Message msg = new Message();
msg.setChar(54, '1');
assert msg.get(new Side()) != null;

Expected behavior It should be a char field, so I can parse the msg locally.

system information:

Additional context N/A

chrjohn commented 1 year ago

On the low level, every field on the FIX message is a String.

You can test the presence of a field by using isSetField(int). Does that answer your question?

orbli commented 1 year ago

does that mean I cannot (or not supposed to) parse a locally assembled message (with type safe way)?

chrjohn commented 1 year ago

If you know what kind of field it is (in your example char): what about using getChar(int)??

orbli commented 1 year ago

If you know what kind of field it is (in your example char): what about using getChar(int)??

yes Message::getChar does not work too

chrjohn commented 1 year ago

I'm confused. Please show the code that your are trying to execute with getChar()

orbli commented 1 year ago

oh i made a mistake, ::getChar works.

The 2nd println is where I got exception, but guess 1st line suffices.

    public static void main(String[] args) throws FieldNotFound {
        quickfix.fix50sp2.ExecutionReport msg = new quickfix.fix50sp2.ExecutionReport();
        msg.setChar(39, '1');
        System.out.println(msg.getChar(39));
        System.out.println(msg.getSide());
    }
chrjohn commented 1 year ago

OK. Side is Tag 54, tag 39 is OrdStatus.