2 Replies Latest reply on Nov 8, 2010 6:53 AM by 567247

    MapListener blocks inserting thread?

      I use local cache and the most basic MapListener. Its entryInserted() method eventually calls Thread.sleep for 2 mins.
      However, I expect that the code that puts an entry into the cache to return immediately after the put.
      What I observe is that put() is blocked for 2 mins until the sleep of the listener is finished.

      Is this correct and what can I do to make the listener asynchronous?
        • 1. Re: MapListener blocks inserting thread?
          Hi opeschan,

          I observed the same behavior when I configure listener (in cache-config.xml) for backing map scheme or for its local cache. But when I configure listener at the distributed-cache level then listener works asynchronously as expected.

          • 2. Re: MapListener blocks inserting thread?
            There is a slightly different behavior here between using a "LocalCache" directly and a Distributed Cache.

            A local cache is a JVM local object that doesn't start threads of its own to manage callbacks. A Distributed Cache on the other hand has a "Distributed Cache Service" that manages eventlisteners and sends the MapListener callbacks on a different thread.

            I'd recommend you to develop using the distributed cache if that is your intended use case long term.