Java Magazine, Sept/Oct 2018
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2018 44 the leading edge Next you need to define the Hystrix command which will get the price for a given stock ticker symbol as shown in Listing 4 Listing 4 Defining the Hystrix command static class PriceCommand extends HystrixCommand Double private final TickerPriceRetrieverService priceDelegate private final String ticker private final RestTemplate restTemplate public PriceCommand TickerPriceRetrieverService priceDelegate String ticker RestTemplate restTemplate HystrixCommand Setter config super config this priceDelegate priceDelegate this ticker ticker this restTemplate restTemplate @ Override public Double run throws Exception return priceDelegate getLatestPrice ticker restTemplate @ Override public Double getFallback return Cache getPrice ticker There are two methods that are usually overwritten in a Hystrix command run and getFallback The run method is the workhorse of the Hystrix command it implements the logic of retrieving
You must have JavaScript enabled to view digital editions.