QuickFIX/J 混合两个不同的版本

QuickFIX/J mixing two different versions

我正在编写一个使用 QuickFIX/J 作为 FIX 框架的应用程序。 我的对方向我发送了 FIX 4.4 版的 ExecutionReport 消息 但只有部分字段(Parties 组件)是 5.0

版本

现在我正在尝试实现我可以读取这个组件。

这个

@Override
public void onMessage(quickfix.fix44.ExecutionReport message, SessionID sessionID)
    throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {

    quickfix.fix50.component.Parties parties = new Parties();
    message.get(parties);
    // ...
}

无效!消息来自版本 4.4,这就是为什么 message.get(...) 只想要一个 quickfix.fix44.component.Parties,而不是版本 5.0

如果我试试这个

@Override
public void onMessage(quickfix.fix50.ExecutionReport message, SessionID sessionID)
    throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {

    // ...
}

我收到以下错误:

Exception in thread "pool-2-thread-1" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    quickfix/fix44/ExecutionReport.get(Lquickfix/field/SettlType;)Lquickfix/field/SettlType; @2: invokevirtual
  Reason:
    Type 'quickfix/field/SettlType' (current frame, stack[1]) is not assignable to 'quickfix/CharField'
  Current Frame:
    bci: @2
    flags: { }
    locals: { 'quickfix/fix44/ExecutionReport', 'quickfix/field/SettlType' }
    stack: { 'quickfix/fix44/ExecutionReport', 'quickfix/field/SettlType' }
  Bytecode:
    0000000: 2a2b b600 5657 2bb0                    

    at quickfix.fix44.MessageFactory.create(MessageFactory.java:195)
    at quickfix.DefaultMessageFactory.create(DefaultMessageFactory.java:133)
    at quickfix.MessageUtils.parse(MessageUtils.java:145)
    at quickfix.mina.AbstractIoHandler.messageReceived(AbstractIoHandler.java:118)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:854)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access00(DefaultIoFilterChain.java:48)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl.messageReceived(DefaultIoFilterChain.java:943)
    at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:405)
    at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:235)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access00(DefaultIoFilterChain.java:48)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl.messageReceived(DefaultIoFilterChain.java:943)
    at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:109)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:535)
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:714)
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:668)
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:657)
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.access0(AbstractPollingIoProcessor.java:67)
    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1121)
    at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

这是因为我正在获取 4.4 字段,但想像对待 4.4 版本一样对待它们。看 here

也许任何人都可以帮助我...

感谢您的努力!!

实现此目的的一种方法是自定义数据字典 FIX4.4.xml 并替换其中有时可能采用 FIX 5.0 格式的字段。例如。通过从 FIX5.0.xml 复制它们并将它们放在 FIX4.4.xml 中的正确消息中。请参阅 QuickFIX/J user FAQ 了解更多详情。

来自QuickFIX/J user manual

The simplest customization is to just modify one or more data dictionaries (e.g., FIX44.xml) and rebuild QFJ. This allows you to add custom fields, define new messages not included in the specification, change whether fields are required or optional, and so on.

之后重建 QuickFIX/J 以反映这些更改。


重建 QuickFIX/J 版本 1 的说明。5.x

You'll need ant installed.

QF/J generates the source from the DDs in core/src/main/resources. Make a back up of the one you're going to alter, and then alter it however you need to.

Then rebuild as follows:

  1. ant jar
  2. You will be prompted for a release number; this just determines the suffix given to the jar names. Enter whatever you want.
  3. Wait for build to finish
  4. Find your brand-new QF/J jars in core/target/

在 FAQ 中更进一步(我如何重建 QF/J)对 ANT 的调用更具体:

The version argument is just a filename suffix. The skip.jalopy argument is optional and will skip some time-consuming doc generation.

ant version=SOME_STRING -Dskip.jalopy=true clean jar


重建 QuickFIX/J 版本 1 的说明。6.x

对于版本 1.6.0,构建是使用 Maven 完成的。

If you are building the code from the command line you'll need to download and install Maven (version 3.2.5 or newer). If you are building from an IDE, Maven is usually included. Building from source requires Java 6+.

  1. Check out the code from GitHub. See the instructions at GitHub for more details on cloning the repository.
  2. Change directory to the top-level directory of the checked out code. You should see a pom.xml file.
  3. Run mvn package to build the QuickFIX/J and examples jar files. This will also generate all the FIX message-related code for the various FIX versions.
  4. There is an option for the code generator to use BigDecimal instead of double for fields like price and quantity. To enable this feature pass a -Dgenerator.decimal option on the command line when running the generate.code target.

There are various command-line switches you can pass to ant to modify the produced behavior:

Switch                  Description                             Default
-Dgenerator.decimal     Generate BigDecimal vs doubles fields   false
-DskipAT=true           Skip running of acceptance test suite.  false

For example, in order to generate fields with BigDecimals and skip acceptance tests:

mvn test -Dgenerator.decimal=true -DskipAT=true 

此问题已在 1.6.3 版本中解决。