KOCA版本 :3.6
KOCA模块 :KCXP
模块版本 :3.6
场景 :在本地搭建了金证高速行情平台,采集期权行情文件,并发送到本地搭建的KCXP,使用KOCA应用读取KCXP中的信息报错
问题 :
使用KOCA应用读取KCXP中的信息报错
消息是可以正常读取到,存储在String中。但是再往下走解析成Map的时候就报错了。
MessageUtils.parseAnsPacket(msg)这一步就报错了。
报错细节 :
java.lang.NumberFormatException: For input string: “{”"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at com.szkingdom.kcbpop.implemention.KCBPPacketUtil.ALLATORIxDEMO(xh:174)
at com.szkingdom.kcbpop.implemention.KCBPPacketOp.putKCBPPacket(to:159)
at com.szkingdom.kcbpop.KCBPOp.KCBPOP_PutKCBPPacket(qf:149)
at com.szkingdom.koca.kcxp.MessageUtils.parseAnsPacket(MessageUtils.java:162)
at com.szkingdom.koca.kcxp.KcxpConnection.getKcxpMessage(KcxpConnection.java:218)
at com.szkingdom.koca.kcxp.KcxpClient.getKcxpMessage(KcxpClient.java:129)
at com.szkingdom.koca.kcxp.KcxpClient.getKcxpMessage(KcxpClient.java:115)
at com.szkingdom.kbms.dataaccess.kcxp.KcxpDemo.getMessage(KcxpDemo.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
消息的样例如下:
{“ZQDM”:“11025508”,“CJSL”:“1”,“CJJE”:“1681509.00”,“ZJJG”:“168.1509”,“JRKP”:“168.1509”,“ZGJG”:“168.1509”,“ZDJG”:“168.1509”,“TotalLongPosition”:“8”,“PreSettlPrice”:“168.1509”,“AuctionPrice”:“168.1509”,“AuctionQty”:“0”,“SettlPrice”:“0.0000”,“SJW1”:“168.1509”,“SJW2”:“0.0000”,“SJW3”:“0.0000”,“SJW4”:“0.0000”,“SJW5”:“0.0000”,“SSL1”:“1”,“SSL2”:“0”,“SSL3”:“0”,“SSL4”:“0”,“SSL5”:“0”,“BJW1”:“0.0000”,“BJW2”:“0.0000”,“BJW3”:“0.0000”,“BJW4”:“0.0000”,“BJW5”:“0.0000”,“BSL1”:“0”,“BSL2”:“0”,“BSL3”:“0”,“BSL4”:“0”,“BSL5”:“0”,“ReservedWord”:“00:00:00.000”,“MDStreamID”:“M0301”,“Timestamp”:“10:28:41.550”,“OrgTradingPhaseCode”:“E 01”}
尝试解决方案:
我看没有使用Koca的旧项目中,没有去调用MessageUtils.parseAnsPacket(msg),而是直接去截取这段JSON,去掉后面的nul,然后就直接用这串JSON