scaleByPowerOfTen(dataDecoder.quote().price().exponent())įinally, let’s ensure our decoded values match the original ones: Assertions.assertEquals(2, dataDecoder.amount()) Īssertions.assertEquals("IBM", dataDecoder.quote().symbol()) Īssertions.assertEquals(Market.NYSE, dataDecoder.quote().market()) Īssertions.assertEquals(Currency.USD, dataDecoder.quote().currency()) Īssertions.assertEquals(128.99, price) 6.Let’s first see the example of XMLEncoder class which is used to serialize or encode a java object into an XML file. Surely, we make use of BigDecimal again: double price = BigDecimal.valueOf(dataDecoder.quote().price().mantissa()) Similarly, we need to decode our price data from two parts, mantissa, and exponent, in order to get the price data into a double value. Next, we decode our TradeData: dataDecoder.wrapAndApplyHeader(buffer, 0, headerDecoder) TradeDataDecoder dataDecoder = new TradeDataDecoder() However, we need decoders, MessageHeaderDecoder and TradeDataDecoder, this time: MessageHeaderDecoder headerDecoder = new MessageHeaderDecoder() To read a message, we’ll use the same buffer instance in which we wrote data. $/generated-sources/java/Īs a result, a typical Maven clean install command generates our Java stubs automatically. So, let’s add the following Maven plugins to our pom.xml: Using SbeTool is easy enough, but we can even make it more practical by integrating it into Maven. However, we still need to define a message. Lastly, we define Quote via composing the other types we created before: įinally, we completed the type definitions. Next, very similar to Market, we create another to represent Currency whose values are mapped as uint8:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |