Dear All,
Per https://stackoverflow.com/questions/48628342/ I have a C# class Geode.cs
that sets up a native client local cache, pool and region and does some work.
I want to reuse the class and have 2 or more local caches that do work
(ultimately to have different
callbacks<http://gemfire-native.docs.pivotal.io/geode/dotnet-caching-api/application-callbacks.html>)
but very simply like in the Program.cs
new Geode();
new Geode();
The 2nd time around to create a new local cache and find the server connection
pool is fine, but to initialise a region at the following code:
IRegion<string, string> test = rf.SetPoolName("myPool").Create<string,
string>("test");
I get the error:
[cid:image001.png@01D39F2C.E14ACEF0]
I have attached a simple test program to show this. Please can you let me know
what’s wrong?
Thanks 😊
Kind regards
Rupert St John Webster
FX Consultant
using Apache.Geode.Client;
using System;
using System.Configuration;
namespace GeodeTest
{
internal class Geode
{
private String _host = ConfigurationManager.AppSettings["GeodeHost"];
private int _port =
Convert.ToInt32(ConfigurationManager.AppSettings["GeodePort"]);
public Geode()
{
CacheFactory cacheFactory = CacheFactory.CreateCacheFactory()
.Set("log-file", "Geode.log")
.Set("log-level", "info")
.Set("statistic-sampling-enabled", "false")
.Set("name", "myCache")
.SetPdxReadSerialized(true);
Cache c = cacheFactory.Create();
Console.WriteLine("Created client cache");
PoolFactory poolFactory = PoolManager
.CreateFactory()
.SetSubscriptionEnabled(true)
.AddLocator(_host, _port)
.SetFreeConnectionTimeout(5000);
Pool p;
if (PoolManager.Find("myPool") == null)
{
p = poolFactory.Create("myPool");
Console.WriteLine("Created client pool");
}
else
{
p = PoolManager.Find("myPool");
Console.WriteLine("Found client pool");
}
RegionFactory rf = c.CreateRegionFactory(RegionShortcut.LOCAL);
// Setup the region
IRegion<string, string> test =
rf.SetPoolName("myPool").Create<string, string>("test");
Console.WriteLine("Created client region");
test["Key1"] = "Value1";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeodeTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("In Main");
new Geode();
new Geode();
Console.WriteLine("Out Main");
}
}
}