blob: 8bd5410b1fefd945fa9a2639d31b8bd4878e31c3 [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine or request Chrome Frame -->
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300italic,400italic,400,600' rel='stylesheet' type='text/css'>
<!-- Use title if it's in the page YAML frontmatter -->
<title>
Registering Interest for Entries |
Geode Native .NET Docs
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/stylesheets/all.css" rel="stylesheet" media="screen, print" />
<link href="/stylesheets/print.css" rel="stylesheet" media="print" />
<link href='/images/favicon.ico' rel='shortcut icon'>
<script src="/javascripts/all.js"></script>
</head>
<body class="docs docs_geode-native docs_geode-native_dotnet docs_geode-native_dotnet_113 docs_geode-native_dotnet_113_regions docs_geode-native_dotnet_113_regions_registering-interest-for-entries has-subnav">
<div class="viewport">
<div class='wrap'>
<script type="text/javascript">
document.domain = "apache.org";
</script>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<header class="header header-layout">
<h1 class="logo">
<a href="/">
<img src="/images/Apache_Geode_logo_symbol_white.png" style="width:30px;">
Apache Geode Native .NET Documentation
</a>
</h1>
<div class="header-links js-bar-links">
<div class="btn-menu" data-behavior="MenuMobile"></div>
<div class="header-item"><a href="http://geode.apache.org">Back to Product Page</a></div>
<div class="header-item">
<a href="http://geode.apache.org/community" target="_blank">Community</a>
</div>
</div>
</header>
<div class="container">
<!--googleoff: index-->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div id="sub-nav" class="js-sidenav nav-container" role="navigation">
<a class="sidenav-title" data-behavior="SubMenuMobile">Doc Index</a>
<div class="nav-content">
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/about-client-users-guide.html">Apache Geode Native Documentation</a>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/getting-started/getting-started-nc-client.html">Getting Started with the Native Library</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/getting-started/getting-started-nc-client.html#set_up_dev_environment">Set Up Your Development Environment</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/getting-started/getting-started-nc-client.html#establish_cluster_access">Establish Access to a Geode Cluster</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/getting-started/getting-started-nc-client.html#app_dev_walkthroughs">Application Development Walkthroughs</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/getting-started/getting-started-nc-client.html#programming_examples">Programming Examples</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/getting-started/put-get-example.html">Put/Get/Remove Examples</a>
</li>
</ul>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/configuring/configuration.html">Configuring a Client Application</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/configuring/system-level-configuration.html">System Level Configuration</a>
</li>
</ul>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/configuring/config-client-cache.html">Configuring the Client Cache</a>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/regions/regions.html">Configuring Regions</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/regions/registering-interest-for-entries.html">Registering Interest for Entries</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/regions/region-attributes.html">Region Attributes</a>
</li>
</ul>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/connection-pools/configuring-pools.html">Configuring Pools</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/connection-pools/client-pool-api.html">Native Client Pool API</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/connection-pools/configuring-pools-attributes-example.html">Pool Configuration Example and Settings</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/connection-pools/subscription-properties.html">Subscription Properties</a>
</li>
</ul>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/serialization/data-serialization.html">Serializing Data</a>
<ul>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/serialization/dotnet-serialization/dotnet-pdx-serialization.html">Geode PDX Serialization</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/serialization/dotnet-serialization/dotnet-pdx-autoserializer.html">Using the Geode PDX Autoserializer</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/serialization/dotnet-serialization/serialize-using-ipdxserializable.html">Using the IPdxSerializable Interface</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/serialization/dotnet-serialization/pdx-serializable-examples.html">IPdxSerializable Example</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/remote-queries.html">Remote Queries</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/continuous-queries.html">Continuous Queries</a>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/security/security.html">Security: Authentication and Encryption</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/security/authentication.html">Authentication</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/security/sslclientserver.html">TLS/SSL Client-Server Communication Encryption</a>
</li>
</ul>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/function-execution.html">Function Execution</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/transactions.html">Transactions</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/configuring/sysprops.html">System Properties</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/client-cache-ref.html">Client Cache XML Reference</a>
</li>
</ul>
</div>
</div>
<!--googleon: index-->
<main class="content content-layout" id="js-content" role="main">
<a id="top"></a>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<span style="font-weight:200;font-size:31px;" style="float:left;">
<img src="/images/Apache_Geode_logo_symbol.png" style="height:26px;">
Apache Geode Native .NET
</span>
<span class="local-header version-info" style="float:right;">
<a href="https://cwiki.apache.org/confluence/display/GEODE/Release+Notes">CHANGELOG</a>
</span>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<h1 class="title-container" >
Registering Interest for Entries
</h1>
<div id="js-quick-links" >
</div>
<div class="to-top" id="js-to-top">
<a href="#top" title="back to top"></a>
</div>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<p>For client regions, you can programmatically register interest in entry keys stored on a cache server region. A client region receives update notifications from the cache server for the keys of interest.</p>
<p>You can register interest for specific entry keys or for all keys. Regular expressions can be used to register interest for keys whose strings match the expression. You can also unregister interest for specific keys, groups of keys based on regular expressions, or for all keys.</p>
<p><strong>Note:</strong> Interest registration and unregistration are symmetrical operations. Consequently, you cannot register interest in all keys and then unregister interest in a specific set of keys. Also, if you first register interest in specific keys with <code>registerKeys</code>, then call <code>registerAllKeys</code>, you must call <code>unregisterAllKeys</code> before specifying interest in specific keys again.</p>
<h2 id="client-api-for-registering-interest"><a id="registering-interest-for-entries__section_C9A3D7F193B24ACD83B2D67813E596A0" class="no-quick-link"></a>Client API for Registering Interest</h2>
<p>You register client interest through the .NET API. The .NET API provides the <code>RegisterKeys</code>, <code>RegisterAllKeys</code>, and <code>RegisterRegex</code> methods, with corresponding unregistration accomplished using the <code>UnregisterKeys</code>, <code>UnregisterAllKeys</code>, and <code>UnregisterRegex</code> methods.</p>
<p>The <code>registerKeys</code>, <code>registerRegex</code> and <code>registerAllKeys</code> methods have the option to populate the cache with the registration results from the server. The <code>registerRegex</code> and <code>registerAllKeys</code> methods can also optionally return the current list of keys registered on the server.</p>
<h2 id="setting-up-client-notification"><a id="registering-interest-for-entries__section_C1A3F89EE73448D7AFF2076F41848F55" class="no-quick-link"></a>Setting Up Client Notification</h2>
<p>In addition to the programmatic function calls, to register interest for a server region and receive updated entries you need to configure the region with the <code>PROXY</code> or <code>CACHING_PROXY RegionShortcut</code> setting. The region&rsquo;s pool should have <code>subscription-enabled=true</code> set either in the client XML or programmatically via a <code>CacheFactory::setSubscriptionEnabled(true)</code> API call. Otherwise, when you register interest, you will get an <code>UnsupportedOperationException</code>.</p>
<pre class="highlight plaintext"><code>&lt;region name="listenerWriterLoader" refid="CACHING_PROXY"&gt;
...
</code></pre>
<p>All clients that have subscriptions enabled track and drop (ignore) any duplicate notifications received. To reduce resource usage, a client expires tracked sources for which new notifications have not been received for a configurable amount of time.</p>
<p><strong>Notification Sequence</strong></p>
<p>Notifications invoke <code>CacheListeners</code> of cacheless clients in all cases for keys that have been registered on the server. Similarly, invalidates received from the server invoke <code>CacheListeners</code> of cacheless clients.</p>
<p>If you register to receive notifications, listener callbacks are invoked irrespective of whether the key is in the client cache when a <code>destroy</code> or <code>invalidate</code> event is received.</p>
<h2 id="registering-interest-for-specific-keys"><a id="registering-interest-for-entries__section_8772147940754C2D9688C789EB2F2AA6" class="no-quick-link"></a>Registering Interest for Specific Keys</h2>
<p>You register and unregister interest for specific keys through the <code>registerKeys</code> and <code>unregisterKeys</code> functions. You register interest in a key or set of keys by specifying the key name using the programmatic syntax shown in the following example:</p>
<pre class="highlight plaintext"><code>keys0.push_back(keyPtr1);
keys1.push_back(keyPtr3);
regPtr0-&gt;registerKeys(keys0);
regPtr1-&gt;registerKeys(keys1);
</code></pre>
<p>The programmatic code snippet in the next example shows how to unregister interest in specific keys:</p>
<pre class="highlight plaintext"><code>regPtr0-&gt;unregisterKeys(keys0);
regPtr1-&gt;unregisterKeys(keys1);
</code></pre>
<h2 id="registering-interest-for-all-keys"><a id="registering-interest-for-entries__section_EA4525CCDC474DD495410E948EAF566C" class="no-quick-link"></a>Registering Interest for All Keys</h2>
<p>If the client registers interest in all keys, the server provides notifications for all updates to all keys in the region. The next example shows how to register interest in all keys:</p>
<pre class="highlight plaintext"><code>regPtr0-&gt;registerAllKeys();
regPtr1-&gt;registerAllKeys();
</code></pre>
<p>The following example shows a code sample for unregistering interest in all keys.</p>
<pre class="highlight plaintext"><code>regPtr0-&gt;unregisterAllKeys();
regPtr1-&gt;unregisterAllKeys();
</code></pre>
<h2 id="registering-interest-using-regular-expressions"><a id="registering-interest-for-entries__section_BD50B80FCE9F429C8F6A9FEA818D5A91" class="no-quick-link"></a>Registering Interest Using Regular Expressions</h2>
<p>The <code>registerRegex</code> function registers interest in a regular expression pattern. The server automatically sends the client changes for entries whose keys match the specified pattern.</p>
<p><em>Keys must be strings in order to register interest using regular expressions.</em></p>
<p>The following example shows interest registration for all keys whose first four characters are <code>Key-</code>, followed by any string of characters. The characters <code>.*</code> represent a wildcard that matches any string.</p>
<pre class="highlight plaintext"><code>regPtr1-&gt;registerRegex("Key-.*");
</code></pre>
<p>To unregister interest using regular expressions, you use the <code>unregisterRegex</code> function. The next example shows how to unregister interest in all keys whose first four characters are <code>Key-</code>, followed by any string (represented by the <code>.*</code> wildcard).</p>
<pre class="highlight plaintext"><code>regPtr1-&gt;unregisterRegex("Key-.*");
</code></pre>
<h2 id="register-interest-scenario"><a id="registering-interest-for-entries__section_2D71A423B185493489129AAC30DC6733" class="no-quick-link"></a>Register Interest Scenario</h2>
<p>In this register interest scenario, a cache listener is used with a cacheless region that has <code>subscription-enabled</code> set to <code>true</code>. The client region is configured with caching disabled; client notification is enabled; and a cache listener is established. The client has not registered interest in any keys.</p>
<p>When a value changes in another client, it sends the event to the server. The server will not send the event to the cacheless client, even though <code>client-notification</code> is set to <code>true</code>.</p>
<p>To activate the cache listener so the cacheless region receives updates, the client should explicitly register interest in some or all keys by using one of the API calls for registering interest. This way, the client receives all events for the keys to which it has registered interest. This applies to Java-based clients as well as non-Java clients.</p>
</main>
</div>
</div>
</div>
<div id="scrim"></div>
<div class="container">
<footer class="site-footer-links">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="copyright">
<a href='/'>Apache Geode Documentation</a>
&copy; 2020 <a href='http://www.apache.org/'>The Apache Software Foundation</a>.
</div>
<div class="support">
Need help? <a href="http://geode.apache.org/community" target="_blank">Visit the Community</a>
</div>
</footer>
</div><!--end of container-->
</body>
</html>