Uploaded image for project: 'Spring Data GemFire'
  1. Spring Data GemFire
  2. SGF-660

Spring Cache Abstraction annotations do not trigger CQ

    XMLWordPrintable

    Details

    • Sprint:
      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.

        Attachments

          Activity

            People

            Assignee:
            jblum John Blum
            Reporter:
            jlouie Jammy Louie
            Last updater:
            John Blum John Blum
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Due:
              Created:
              Updated:
              Resolved: