QuickFIX/J自定义消息解码器解决“did not find checksum field, bad length?”问题

什么是QuickFIX/J

下面我们来看一下QuickFIX/J官网的介绍:

The Financial Information eXchange (FIX) protocol is a messaging standard developed specifically for the real-time electronic exchange of securities transactions. FIX is a public-domain specification owned and maintained by FIX Protocol, Ltd (FPL).

QuickFIX/J is a full featured messaging engine for the FIX protocol. It is a 100% Java open source implementation of the popular C++ QuickFIX engine.

简单来说,FIX协议就是金融信息交换协议,是专门为证券交易的实时电子交换而开发的消息传递标准,这是目前金融行业普遍采用的金融信息交换协议。

而QuickFIX/J就是一个100%由Java开发的开源FIX消息传递引擎,通过使用这个引擎就可以很方便地搭建出标准的FIX协议消息传递的服务。

在实际使用中遇到的问题

在最近的项目开发中,需要搭建一个FIX协议客户端接收第三方服务端推送来的行情信息。通过使用QuickFIX/J,很快就搭建出来了服务的雏形,但在进行联调测试的时候就傻眼了,服务运行起来就不停地报错:

“did not find checksum field, bad length?”。后来经过排查,发现是由于客户服务端发送来的FIX消息不标准导致的,具体来说就是FIX消息里的消息体长度字段(9=?)的数值是错误的,因此无法通过QuickFIX引擎反序列化出完整的消息,导致在消息末尾的校验和字段丢失,就会一直报错。

下面就是在quickfix.mina.message.FIXMessageDecoder中进行校验的地方:

if (position + CHECKSUM_PATTERN.getMinLength() <= in.limit()) {
   
   
  // FEATURE allow configurable recovery position
  // int recoveryPosition = in.position() + 1;
  // Following recovery position is compatible with QuickFIX C++
  // but drops messages unnecessarily in corruption scenarios.
  int recoveryPosition = position + 1;
  handleError(in, recoveryPosition,
        "did not find checksum field, bad length?", isLogon(in));
  continue;
} else 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值