Imported from previous forum
I am new to OPEN FAST development. I’m sending a logon message as follows.
MessageTemplateLoader templateLoader = new XMLMessageTemplateLoader();
MessageTemplate[] marketDataTemplateArray = templateLoader.load(new FileInputStream(templatesFile));
String newPwd = pwd;
MessageTemplate marketDataTemplate = templateLoader.getTemplateRegistry().get("Logon");
templateLoader.getTemplateRegistry().register(1, marketDataTemplate);
Message logonMessage = new Message(marketDataTemplate);
logonMessage.setString("MsgType", "A");
SimpleDateFormat df = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
logonMessage.setString("SendingTime", df.format(new Date()));
logonMessage.setInteger("HeartBtInt", 10);
logonMessage.setString("UserName", "bobs");
logonMessage.setString("Password", "abcd");
MessageOutputStream outF = new MessageOutputStream(connection.getOutputStream());
outF.registerTemplate(1, marketDataTemplate);
outF.writeMessage(logonMessage);
But at the server reject the message telling ‘message doesn’t contain the message length’. I think reason is inside the OPEN FAST it doesn’t include the message length to the packet. Here is the first half of the bit representation of the logon message.
Input :
-
1 1 0 0 0 0 0 0 |0x40| |64| |0| |@| -
1 0 0 0 0 0 0 1 |0x1| |1| |1| |N/A| -
1 1 0 0 0 0 0 1 |0x41| |65| |-1| |A| -
0 0 1 1 0 0 1 0 |0x32| |50| |50| |2| -
0 0 1 1 0 0 0 0 |0x30| |48| |48| |0| -
0 0 1 1 0 0 0 1 |0x31| |49| |49| |1| -
0 0 1 1 0 0 0 1 |0x31| |49| |49| |1|
can some one please help to add message length to the packet.
I think is solution is to add additional field to message to indicate the message length. To do that I need to get the byte length of the openfast.Message. Can some help me to do that…?