package name.webdizz.fault.tolerance.inventory.endpoint;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import name.webdizz.fault.tolerance.inventory.domain.Inventory;
import name.webdizz.fault.tolerance.inventory.domain.Product;
import name.webdizz.fault.tolerance.inventory.domain.Store;
import name.webdizz.fault.tolerance.inventory.repository.InventoryRepository;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@RestController
@RequestMapping("/inventories")
public class InventoryEndpoint {

    @Autowired
    private InventoryRepository inventoryRepository;

    @HystrixCommand(commandKey = "RequestInventory")
    @RequestMapping("/{store}/{product}")
    public Inventory requestInventory(@PathVariable("store") String storeId, @PathVariable("product") String productId) {
        Store store = new Store(storeId);
        Product product = new Product(productId);
        return inventoryRepository.read(product, store);
    }

    @HystrixCommand(commandKey = "SaveInventory")
    @RequestMapping(value = "/{store}/{product}", method = RequestMethod.POST)
    public void saveInventory(@PathVariable("store") String storeId, @PathVariable("product") String productId, @RequestBody Long amount) {
        Store store = new Store(storeId);
        Product product = new Product(productId);
        Inventory inventory = new Inventory(store, product, amount);
        inventoryRepository.save(inventory);
    }
}

@@ -758,16 +758,88 @@
 Command;
+%0Aimport com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
 %0A%0A@RestC
@@ -1026,32 +1026,181 @@
 equestInventory%22
+, threadPoolKey = %22RequestInventoryThreadPool%22, threadPoolProperties = %7B@HystrixProperty(name = %22hystrix.threadpool.default.coreSize%22, value = %2250%22)%7D
 )%0A    @RequestMa
@@ -1505,16 +1505,16 @@
 %0A    %7D%0A%0A
-
     @Hys
@@ -1553,16 +1553,119 @@
 ventory%22
+, threadPoolProperties = %7B@HystrixProperty(name = %22hystrix.threadpool.default.coreSize%22, value = %2250%22)%7D
 )%0A    @R

Configure thread pools for inventory service