This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<flow name="main"> | |
<zeromq:inbound-endpoint address="tcp://*:9090" socket-operation="bind" | |
exchange-pattern="request-response"/> | |
<protobuf:deserialize | |
protobufClass="com.acmesoft.stock.model.serialization.protobuf.StockQuoteRequestBuffer"/> | |
<expression-transformer | |
expression="com.acmesoft.stock.model.StockQuoteRequest.fromProtocolBuffer(payload)"/> | |
<component class="com.acmesoft.stock.service.StockDataServiceImpl"/> | |
<expression-transformer | |
expression="return com.acmesoft.stock.model.StockQuote.toProtocolBuffer(payload)"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.zeromq</groupId> | |
<artifactId>zmq</artifactId> | |
<version>2.2.0</version> | |
<systemPath>/usr/local/lib/zmq.jar</systemPath> | |
<scope>system</scope> | |
</dependency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static StockQuoteResponseBuffer toProtocolBuffer(List<StockQuote> quotes) { | |
StockQuoteResponseBuffer.Builder responseBuilder = StockQuoteResponseBuffer.newBuilder(); | |
for (StockQuote quote : quotes) { | |
responseBuilder.addResult(StockQuoteBuffer.newBuilder() | |
.setAdjustedClose(quote.getAdjustedClose()) | |
.setClose(quote.getClose()) | |
.setDate(quote.getDate().getTime()) | |
.setHigh(quote.getHigh()) | |
.setLow(quote.getLow()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public byte[] toProtocolBufferAsBytes() { | |
return StockQuoteRequestBuffer.newBuilder() | |
.setSymbol(symbol) | |
.setStart(startDate.getTime()) | |
.setEnd(endDate.getTime()).build().toByteArray(); | |
} | |
public static StockQuoteRequest fromProtocolBuffer(StockQuoteRequestBuffer buffer) { | |
StockQuoteRequest request = new StockQuoteRequest(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<plugin> | |
<groupId>com.google.protobuf.tools</groupId> | |
<artifactId>maven-protoc-plugin</artifactId> | |
<configuration> | |
<protocExecutable>/usr/local/bin/protoc</protocExecutable> | |
</configuration> | |
<executions> | |
<execution> | |
<goals> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.acmesoft.zeromq; | |
option java_package = "com.acmesoft.stock.model.serialization.protobuf"; | |
option optimize_for = SPEED; | |
option java_multiple_files = true; | |
message StockQuoteResponseBuffer { | |
repeated StockQuoteBuffer result = 1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.acmesoft.zeromq; | |
option java_package = "com.acmesoft.stock.model.serialization.protobuf"; | |
option optimize_for = SPEED; | |
option java_multiple_files = true; | |
message StockQuoteRequestBuffer { | |
required string symbol = 1; | |
required int64 start = 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface StockDataService { | |
public List<StockQuote> getQuote(StockQuoteRequest request); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StockQuoteRequest implements Serializable { | |
String symbol; | |
Date startDate; | |
Date endDate; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StockQuote implements Serializable { | |
String symbol; | |
Date date; | |
Double open; | |
Double high; |