Giter Site home page Giter Site logo

nanofix's People

Contributors

dmeow17 avatar fillreject avatar juddgaddie avatar mikeb01 avatar nickelaway avatar singlaj avatar swarren12 avatar thebeanogamer avatar thody1994 avatar tom-smalls avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nanofix's Issues

Functionality of blockingStart() method code of ByteChannelReader class

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

https://github.com/LMAX-Exchange/nanofix/blob/master/nanofix-client/src/main/java/com/lmax/nanofix/ChannelInitializer.java

@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();
}

https://github.com/LMAX-Exchange/nanofix/blob/master/nanofix-client/src/main/java/com/lmax/nanofix/incoming/ByteChannelReader.java

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();
        }
    }
}

Invalid FIX Message Header

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.