4 Replies Latest reply on Mar 18, 2013 11:23 AM by 917390

    MultiplexingMapListener onMapEvent never gets old value

      h1. Overview

      Cache: Coherence
      Client: C++ (Coherence

      We have a cache of "states" (one entry for each of the four things we're interested in in our system).

      On the Java side we extend AbstractProcessor. This is invoked to handle inserts/updates to the states in the cache.

      On the C++ (client) side we have a continuous query which "listens" for updates to the state.

      When I fiire state changes the Java processor "process" method is invoked (which is fine). I debug through it and it does its job - no exceptions and no NULL pointers.

      h1. The Problem

      When the Java "process" method completes my C++ client onMapEvent method is invoked.
      Calling vEvent->getNewValue() gets the correct new value.
      Calling vEvent->getOldValue() always returns null. We never get the old state even though state exists in the cache before the update.

      Does anyone know why the old value is not being set?


      h1. Code

      h2. Java (pseudo code)

      public Object process(Entry entry)
      // Some logic...
      ProdState newState = new ProdState(/*New values*/);

      return newState;
      catch (Throwable t)
      // Log.

      return null;

      h2. C++ Client (initialization)

      // Subscribe to all ProdState entries.
      coherence::util::Filter::Handle filter = coherence::util::filter::AlwaysFilter::create();

      m_hProdStateQuery = coherence::net::cache::ContinuousQueryCache::create(m_hCacheProductState,

      h2. C++ Client (listener)

      *// NOTE: ProdStateListener extends MultiplexingMapListener*

      void ProdStateListener::onMapEvent(MapEvent::View vEvent)
                *// PROBLEM: oldState is always NULL.*     

      Managed<ProdState>::View oldState =

                *// newState is correct.*     

      Managed<ProdState>::View newState =

                // ...notify observers.

           catch(const std::exception& ex)
                std::cout << ex.what() << std::endl;
        • 1. Re: MultiplexingMapListener onMapEvent never gets old value

          A couple of questions.
          1) Can you post a snippet of code calling your EntryProcessor? Is it called from Java or C++?
          2) In your EntryProcessor, are you able to try the following instead of creating a new ProdState() object.
          ProdState prodState = (ProdState) entry.getValue();
          // Call setters to change values for prodState.
          3) Are you sure you are updating the same key for the ProdState object?


          • 2. Re: MultiplexingMapListener onMapEvent never gets old value
            Hi DonLonDon,

            Your EP and CQC look valid enough.

            Have you tried replacing the CQC with a near-cache, or even attaching the listener directly to the grids distributed cache? This might help to isolate your issue, as it may be purely CQC related. If all three result in the same issue its much more likely to be the EP.

            • 3. Re: MultiplexingMapListener onMapEvent never gets old value

              Perhaps the ContinuousQueryCache constructor is registering the listener in "lite" mode (see method addFilterListener in http://docs.oracle.com/cd/E24290_01/coh.371/e22845/classcoherence_1_1util_1_1_observable_map.html).

              To verify, trying explicitly adding a listener using addFilterListener setting "fLite" to false.

              It may not be useful as a solution to your problem, in that adding the listener afterwards means you'll miss the events arising from initial population of the CQC, but may at least clarify what's happening.

              • 4. Re: MultiplexingMapListener onMapEvent never gets old value
                Thanks for the suggestions - unfortunately I haven't had time to try any of them out so haven't identified the root cause.

                We came up with a workaround based on data in our newState object.

                As I'm moving on to new development pastures I doubt I'll get chance to look at this problem again but would be interested if anyone solves it.

                Thanks again.