Java Magazine, Sept/Oct 2018
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2018 38 the leading edge You will need knowledge of Spring Boot and Maven to follow along because I will use these technologies in this article Setting the Stage Imagine that you need to write a microservice that displays your stock brokerage account holdings specifically when you give it a user name it will return the number of shares the user owns the price of these shares and the value of the holdings number of shares multiplied by price per share To accomplish this task you need to rely on a microservice created by your teammate which accepts the ticker symbol of the stock and returns its price Lets look first at the price microservice that gives you the price of the stock Listing 1 Listing 1 A simple service that returns a stock price @ RestController public class TickerServiceController @ RequestMapping value getTickerPrice ticker method RequestMethod GET public Double getTickerPrice@ PathVariable String ticker Random r new Random long processingTime long r nextGaussian stdDevProcessingTimeInMillis meanProcessingTimeInMillis try Thread sleep processingTime catch InterruptedException e LOGGER error e getMessage e
You must have JavaScript enabled to view digital editions.