Created
December 25, 2014 21:39
-
-
Save maxant/99a429d20993a362428b to your computer and use it in GitHub Desktop.
The trading engine actor class.
This file contains 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
private static class TradingEngineActor extends AbstractActor { | |
// STATE | |
private TradingEngine engine = new TradingEngine(DELAY, TIMEOUT, (type, data) -> handle(type, data), true); | |
public TradingEngineActor() throws NamingException { | |
// INBOX | |
receive(ReceiveBuilder | |
.match(SalesOrder.class, so -> { | |
// BEHAVIOUR (delegated to engine) | |
engine.addSalesOrder(so.getSeller().getName(), | |
so.getProductId(), | |
so.getRemainingQuantity(), | |
so.getPrice(), so.getId()); | |
}) | |
.match(PurchaseOrder.class, po -> { | |
... | |
.match(String.class, s -> RUN.equals(s), command -> { | |
engine.run(); | |
}) | |
.build()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment