lmax-exchange / nanofix Goto Github PK
View Code? Open in Web Editor NEWA fix client for testing FIX servers
License: Apache License 2.0
A fix client for testing FIX servers
License: Apache License 2.0
Gentleman,
Sorry for the form of this question (as an open issue) but it seems, it is only one possibility for me to connect you.
I have been investigating a your code, and as self training, especially in a term of Java non blocking sockets, I have decided to add SSL encapsulation to the client part of your code. I have almost completed, I can connect to my LMAX demo account, to log in using FIX message and receive response. But during code investigation, I have noticed the code of connectionEstablished() method of ChannelInitializer.java, which is called just after socket is connected (called in observer), which calls blockingStart() method of ByteChannelReader.java.
To reach my assumption (to connect my LMAX demo account) I had to comment this part of code if leaved as is - each connection is closed just after it is established. As I probably don't understand a big picture of design, my question is: what this code really does? I mean the code: Connection established observer which calls:connectionEstablished() method of:ChannelInitializer.java, which calls: inputStreamReader.blockingStart(readableByteChannel); Being precise, I don't undestand the functionality the code inside blockingStart() method.
Can you help to understand this?
Thank you in advance for each minute spent on writing a response.
Best regards,
Piotr
@Override
public void connectionEstablished()
{
outboundMessageSender.initialiseOutboundChannel(transport.getWritableByteChannel());
channelReaderExecutorService.execute(new Runnable()
{
@Override
public void run()
{
final ReadableByteChannel readableByteChannel = transport.getReadableByteChannel();
try
{
inputStreamReader.blockingStart(readableByteChannel);
}
catch (RuntimeException e)
{
LOGGER.error("Exception thrown while reading from stream, channel: " + readableByteChannel, e);
}
}
});
countDownLatch.countDown();
}
public void blockingStart(final ReadableByteChannel readableByteChannel)
{
try
{
while ((readableByteChannel.read(buffer)) != -1)
{
blocker.mayWait();
buffer.flip();
byteStreamMessageParser.parse(buffer);
buffer.clear();
}
}
catch (final ClosedChannelException e)
{
//Yes closed.
}
catch (final IOException e)
{
LOGGER.error("An error occurred trying to read from the socket", e);
}
finally
{
if (readableByteChannel != null)
{
try
{
if (readableByteChannel.isOpen())
{
readableByteChannel.close();
}
}
catch (IOException e)
{
//I don't care
}
connectionObserver.connectionClosed();
}
}
}
When using the FixMessageBuilder object, if you're building a fix message whose message type is not predefined in the MsgType object then you have to use the append() method the builder provides. If the first call to the builder is not appending the MsgType, then the fix message produced is invalid (MsgType will not be the 3rd fix tag.
Valid Message: 8=FIX.4.2|9=64|35=4|123=Y|36=10|56=tom|49=JUDD|52=20160808-12:02:50.967|34=100|10=237|
new FixMessageBuilder()
.append(35, "4")
.msgSeqNum(100)
.append(123, "Y")
.append(36, "10")
.send();
Invalid Message: 8=FIX.4.2|9=64|34=100|123=Y|35=4|36=10|56=tom|49=JUDD|52=20160808-12:02:50.967|10=237|
new FixMessageBuilder()
.msgSeqNum(100)
.append(123, "Y")
.append(35, "4")
.append(36, "10")
.send();
The Standard Message Header for FIX defines that MsgType should be the third field in a message (http://btobits.com/fixopaedia/fixdic44/index.html)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.