Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-10130

Remote cache calls from client listener get stuck

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Major Major
    • None
    • 9.4.12.Final, 10.0.0.Final, 13.0.1.Final
    • Listeners, Remote Protocols
    • Workaround Exists
    • Hide

      If value information is needed, an existing converter can be used whereby the value created gets shipped back as part of the listener callback, e.g.

      public class RemoteCacheGetFromListenerTest extends SingleHotRodServerTest {
      
         public void test000() throws InterruptedException {
            final RemoteCache<String, Object> remoteCache = remoteCacheManager.getCache();
            remoteCache.addClientListener(new RemoteListener2(remoteCache));
      
            final String key = UUID.randomUUID().toString();
            remoteCache.put(key, 12345);
            Thread.sleep(1000);
      
            remoteCache.put(key, 23456);
         }
      
         @ClientListener(converterFactoryName = "key-value-with-previous-converter-factory")
         private static class RemoteListener2 {
      
            private final RemoteCache<String, Object> remoteCache;
      
            public RemoteListener2(RemoteCache<String, Object> remoteCache) {
               this.remoteCache = remoteCache;
            }
      
            @ClientCacheEntryCreated
            public void handleCreatedEvent(ClientCacheEntryCustomEvent<KeyValueWithPrevious<String, Object>> event) {
               System.out.println("RemoteListener.handleCreatedEvent: " + event);
               System.out.println(event.getEventData().getValue());
            }
      
         }
      
      }
      
      Show
      If value information is needed, an existing converter can be used whereby the value created gets shipped back as part of the listener callback, e.g. public class RemoteCacheGetFromListenerTest extends SingleHotRodServerTest { public void test000() throws InterruptedException { final RemoteCache< String , Object > remoteCache = remoteCacheManager.getCache(); remoteCache.addClientListener( new RemoteListener2(remoteCache)); final String key = UUID.randomUUID().toString(); remoteCache.put(key, 12345); Thread .sleep(1000); remoteCache.put(key, 23456); } @ClientListener(converterFactoryName = "key-value-with-previous-converter-factory" ) private static class RemoteListener2 { private final RemoteCache< String , Object > remoteCache; public RemoteListener2(RemoteCache< String , Object > remoteCache) { this .remoteCache = remoteCache; } @ClientCacheEntryCreated public void handleCreatedEvent(ClientCacheEntryCustomEvent<KeyValueWithPrevious< String , Object >> event) { System .out.println( "RemoteListener.handleCreatedEvent: " + event); System .out.println(event.getEventData().getValue()); } } }

      Remote cache get() call from within a ClientListener callback gets stuck, e.g.

      @Test(testName = "client.hotrod.MusaTest")
      public class RemoteCacheGetFromListenerTest extends SingleHotRodServerTest {
      
         public void test000() throws InterruptedException {
            final RemoteCache<String, Object> remoteCache = remoteCacheManager.getCache();
            remoteCache.addClientListener(new RemoteListener2(remoteCache));
      
            remoteCache.put(UUID.randomUUID().toString(), 12345);
            Thread.sleep(1000);
         }
      
         @ClientListener()
         private static class RemoteListener2 {
      
            private final RemoteCache<String, Object> remoteCache;
      
            public RemoteListener2(RemoteCache<String, Object> remoteCache) {
               this.remoteCache = remoteCache;
            }
      
            @ClientCacheEntryCreated
            public void handleCreatedEvent(ClientCacheEntryCreatedEvent<String> event) {
               System.out.println("RemoteListener.handleCreatedEvent: " + event);
               System.out.println(remoteCache.get(event.getKey()));
            }
      
         }
      
      }
      

              Unassigned Unassigned
              rh-ee-galder Galder ZamarreƱo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: