This discussion is archived
4 Replies Latest reply: Mar 18, 2013 4:23 AM by 917390 RSS

MultiplexingMapListener onMapEvent never gets old value

917390 Newbie
Currently Being Moderated
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
    tmiddlet Newbie
    Currently Being Moderated

    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
    user123799 Newbie
    Currently Being Moderated
    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
    DJW Newbie
    Currently Being Moderated

    Perhaps the ContinuousQueryCache constructor is registering the listener in "lite" mode (see method addFilterListener in

    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
    917390 Newbie
    Currently Being Moderated
    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.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points