Reputation: 131
I am new to the world of FiX and currently learning how to send fix messages between apps in Java.
I came across this Spring Boot starter which basically reduces the boiler plate code. I have two spring boot starters; one acting as the initiator (client) and the other is the server (acceptor).
I've had a look at their examples on the repo and even though it was pretty defined with the multiple scenarios, I'm having trouble sending a simple FiX message from my client to the server.
My client code consists of a controller in which when the endpoint is called; it sends the following fix message (my main class is literally your usual spring main class but it's annnotated with @EnableQuickFixJClient
and @SpringBootApplication
):
@RestController
public class SendMessageViaRest
{
@Autowired
QuickFixJTemplate quickFixJTemplate;
@GetMapping("/bob")
public void sendFix()
{
System.out.println("HERHER");
Message message = new Message();
quickfix.Message.Header header = message.getHeader();
message.setField(new OrigClOrdID("3434"));
header.setField(new BeginString("FIX.4.1"));
header.setField(new SenderCompID("BANZAI"));
header.setField(new TargetCompID("EXEC"));
header.setField(new MsgType("D"));
message.setField(new OrigClOrdID("123"));
message.setField(new ClOrdID("321"));
message.setField(new HandlInst('3')); //CHANGE THIS TO RANDOM VALUE TO SEE WHAT HAPPENS
message.setField(new OrdType('1'));
message.setField(new Symbol("LNUX"));
message.setField(new TransactTime(LocalDateTime.now()));
message.setField(new Side(Side.BUY));
message.setField(new Text("Cancel My Order!"));
quickFixJTemplate.send(message);
}
}
And my server code base literally just has a main method and thats it:
@EnableQuickFixJServer
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
When i start both apps, I can see the logon request/response and the heartbeats on the output of both apps. But when i call the endpoint in the client app; I get the following error:
quickfix.FieldException: Tag not defined for this message type, field=41
. Why is this the case as I have set it on the message?
Futhermore, just a question i thought of; This class in one of the examples extends MessageCracker.. let's assume the following scenario: the client talks to 2 servers; one server communicating in 4.1 and the other sever communicating on 4.2. If both servers sent a orderCancelRequest message, then how would it know which version of the protocol to parse the message in? I ask this because in the config class they're wiring in one message cracker for the app so what if your client needs to handle multiple version of fix? How would this be achieved?
Upvotes: 0
Views: 540