[ 
https://issues.apache.org/jira/browse/GEODE-8592?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Martell updated GEODE-8592:
-----------------------------------
    Description: 
As reported on StackOverflow 
([https://stackoverflow.com/questions/64045931/repeated-ui-calls-to-geode-native-client-attributesmutator-setcachelistener)],
 this looks like a bug with AttributesMutator when setting multiple 
CacheListeners.

 

Direct from SO:

If I have a button on a UI that registers a listener, sync not async, and click 
it several times, then repeatedly setting listeners on a region hangs:

A {{Cache c}} is already initialized. This is using the C# Geode Native Client.

{code:C#}
IRegion<string, Object> d = c.GetRegion<string, Object>("deal");

try

{ Logs.Trace("Registering key"); d.GetSubscriptionService().RegisterKeys(s); 
d.AttributesMutator.SetCacheListener(new LDeal<string, Object>(c, AddDeal)); }

catch (Exception ex)

{ new ApplicationException("Can't register key: " + clOrdId, ex); }

}}
{code:C#}

Is this an optimal way to set a listener on a region? If it's going to hang how 
can I have a timeout so that setting a listener is better managed?

UPDATE: using {{async}} / {{await}} appears to resolve this issue, so that the 
{{SetCacheListener}} becomes
{code:java}
 

{{await Task.Run(() => d.AttributesMutator.SetCacheListener(new LDeal<string, 
Object>(c, AddDeal)));}}

{{}}
{code:java}
 {code}
{{}}

  was:
As reported on StackOverflow 
([https://stackoverflow.com/questions/64045931/repeated-ui-calls-to-geode-native-client-attributesmutator-setcachelistener)],
 this looks like a bug with AttributesMutator when setting multiple 
CacheListeners.

 

Direct from SO:

If I have a button on a UI that registers a listener, sync not async, and click 
it several times, then repeatedly setting listeners on a region hangs:

A {{Cache c}} is already initialized. This is using the C# Geode Native Client.

 
{code:java}
{{IRegion<string, Object> d = c.GetRegion<string, Object>("deal");

try

{ Logs.Trace("Registering key"); d.GetSubscriptionService().RegisterKeys(s); 
d.AttributesMutator.SetCacheListener(new LDeal<string, Object>(c, AddDeal)); }

catch (Exception ex)

{ new ApplicationException("Can't register key: " + clOrdId, ex); }

}}
{code:java}
 {code}
Is this an optimal way to set a listener on a region? If it's going to hang how 
can I have a timeout so that setting a listener is better managed?

UPDATE: using {{async}} / {{await}} appears to resolve this issue, so that the 
{{SetCacheListener}} becomes

{code:}

 

{{await Task.Run(() => d.AttributesMutator.SetCacheListener(new LDeal<string, 
Object>(c, AddDeal)));}}

{{}}
{code:java}
 {code}
{{}}


> Hang in SetCacheListener
> ------------------------
>
>                 Key: GEODE-8592
>                 URL: https://issues.apache.org/jira/browse/GEODE-8592
>             Project: Geode
>          Issue Type: Bug
>          Components: native client
>            Reporter: Michael Martell
>            Priority: Minor
>
> As reported on StackOverflow 
> ([https://stackoverflow.com/questions/64045931/repeated-ui-calls-to-geode-native-client-attributesmutator-setcachelistener)],
>  this looks like a bug with AttributesMutator when setting multiple 
> CacheListeners.
>  
> Direct from SO:
> If I have a button on a UI that registers a listener, sync not async, and 
> click it several times, then repeatedly setting listeners on a region hangs:
> A {{Cache c}} is already initialized. This is using the C# Geode Native 
> Client.
> {code:C#}
> IRegion<string, Object> d = c.GetRegion<string, Object>("deal");
> try
> { Logs.Trace("Registering key"); d.GetSubscriptionService().RegisterKeys(s); 
> d.AttributesMutator.SetCacheListener(new LDeal<string, Object>(c, AddDeal)); }
> catch (Exception ex)
> { new ApplicationException("Can't register key: " + clOrdId, ex); }
> }}
> {code:C#}
> Is this an optimal way to set a listener on a region? If it's going to hang 
> how can I have a timeout so that setting a listener is better managed?
> UPDATE: using {{async}} / {{await}} appears to resolve this issue, so that 
> the {{SetCacheListener}} becomes
> {code:java}
>  
> {{await Task.Run(() => d.AttributesMutator.SetCacheListener(new LDeal<string, 
> Object>(c, AddDeal)));}}
> {{}}
> {code:java}
>  {code}
> {{}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to