Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.0 RC2 (Kay), 2.0 GA (Kay)
-
Spring Data GemFire + Pivotal GemFire
-
Kay GA, Kay SR1
Description
When implementing a CQ, it does not trigger when a method is annotated with @Cachable or @CachePut. However, a CQ is triggered when a method is annotated with @CacheEvict. This should be consistent and a @Cachable or @CachePut annotated service method should trigger a CQ.
Sample code can be found here:
https://github.com/pivotal-Jammy-Louie/PCC-Pizza
Scenario:
- Created a Region called "PizzaOrder"
- Created a CQ Query: "SELECT * FROM /PizzaOrder"
- The CQ Listener/handler just performs a System.out.println(..) to indicate to me that it has been triggered.
- I use the following in my service:
@Cacheable(value = "PizzaOrder") public PizzaOrder getPizzaOrder(long pizzaOrderId){ this.simulateSlowService(); return this.pizzaOrderRepository.findById(pizzaOrderId).orElse(null); } @CachePut(value = "PizzaOrder") public PizzaOrder createOrder (long customerId, long pizzaId){ Customer customer = this.customerRepository.findById(customerId).orElse(null); Pizza pizza = this.pizzaRepository.findById(pizzaId).get(); PizzaOrder order = new PizzaOrder(customer, pizza); return this.pizzaOrderRepository.save(order); } @CacheEvict(value = "PizzaOrder") public PizzaOrder completePizzaOrder(long pizzaOrderId){ PizzaOrder pizzaOrder = this.pizzaOrderGemfireRepository.findById(pizzaOrderId).orElseGet(()->this.getPizzaOrder(pizzaOrderId)); pizzaOrder.setOrderComplete(true); return this.pizzaOrderRepository.save(pizzaOrder); }
When the method completePizzaOrder is invoked I can see that the CQ is triggered but the other annotations do not trigger the CQ.
If I perform a put through GFSH I can see the CQ trigger.