Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated messages should return header from their fix version #801

Open
Svanar opened this issue Apr 29, 2024 · 2 comments
Open

Generated messages should return header from their fix version #801

Svanar opened this issue Apr 29, 2024 · 2 comments

Comments

@Svanar
Copy link

Svanar commented Apr 29, 2024

Is your feature request related to a problem? Please describe.
Generated messages should have overridden getHeader() method to return header that corresponds to used protocol version.

Describe the solution you'd like
In order to set header fields I would like to have returned header that if specific to fix version that message comes from.
I presented that with code example in additional context.

What I think would be nice is to make method getHeader return quickfix.fix44.Message.Header so building messages can be done without any casting, making it more fluent.
What is more changing behavior to one I described would make it easier to work with for new devs, because IDE would hint available methods.

Describe alternatives you've considered
Casting quickfix.Message.Header to actual header, for example quickfix.fix44.Message.Header

Additional context
Example code pattern that I currently use, but it is a bit tedious to write it each time I add fields in header.

import quickfix.Message;
import quickfix.field.TargetSubID;
import quickfix.fix44.QuoteRequest;

class Main {

    public static void main(String[] args) {
        QuoteRequest quoteRequest = new QuoteRequest();

        Message.Header header = quoteRequest.getHeader();
        // header.set(new TargetSubID("subId")); // Does not work

        // casting is needed
        quickfix.fix44.Message.Header fix44Header = (quickfix.fix44.Message.Header) header;
        fix44Header.set(new TargetSubID("subId"));

    }

}
@chrjohn
Copy link
Member

chrjohn commented Apr 29, 2024

Thanks for opening this issue.

If you're not tied to using the type safe methods you could also use e.g.:

public void setString(int field, String value) {

@Svanar
Copy link
Author

Svanar commented Apr 30, 2024

That was one of my attempts and while it is working I think that having it type safe makes it great and generated classes are really good with that hence my idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants