2 Replies Latest reply: Nov 8, 2010 12:53 AM by 567247 RSS

    MapListener blocks inserting thread?

    338845
      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?
          751171
          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.

          Denis.
          • 2. Re: MapListener blocks inserting thread?
            567247
            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.

            /Christer