You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geode.apache.org by Ali Koyuncu <al...@gmail.com> on 2016/05/23 08:24:06 UTC

Question about Region Events

Dear all,

I created a region named Operation.

What I want to do is to get notified upon creating or updating record in
this region.

Following are my code segments:

*Listener (named OperationCacheListener):*

  public void afterCreate(EntryEvent event) {

   iEvent message = (iEvent) event.getNewValue();

   if(message instanceof CmdStartCSS)
   {
    logger.debug("[OperationCacheListener][Command: Start][Key: {}]");

    try {
    CmdStartCSS command = (CmdStartCSS) event.getNewValue();
    DialManager.getInstance().Start(command);
    }
    catch(Exception e)
    {
    logger.error("[OperationCacheListener][Start][{}][Exception: {}]",
e.getClass().getSimpleName(), e.getMessage());
    }

   }
   else if(message instanceof CmdStopCSS)
   {
    logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
    try {
DialManager.getInstance().Stop();
} catch (Exception e) {
//
}
   }

  }

  public void afterUpdate(EntryEvent event)
  {
 System.err.println("Region entry was updated.");
  }


*How I initiate the listener:*

this.listener = new OperationCacheListener();
this.OperationRegion = cache
.<String,
iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
.initCacheListeners(new CacheListener[]
   {this.listener})
.create(OperationRegionName);


*PROBLEM:*

When I am to create/update a record in this region, my events are not
triggered.

Could you please check and tell me where I am wrong or missing? (If you
have a sample code on this matter, I will be glad).

Thank you in advance.


-- 

Saygılarımla, with my warm regards,

Ali KOYUNCU

Re: Question about Region Events

Posted by Ali Koyuncu <al...@gmail.com>.
Dear friends,

Thank you all for your support.

Let me share the code segment with you:

*How to define ClientCache*

ClientCache cache = new ClientCacheFactory()
.addPoolLocator(IP, Port)
.setPoolSubscriptionEnabled(*true*)
.create();


*and how to define/register the listener:*


Region<String, Object> this.OperationRegion = cache
.<String, Object>createClientRegionFactory(ClientRegionShortcut.PROXY)
.addCacheListener(new OperationCacheListener())
.create("Operation");

OperationRegion.registerInterest("*ALL_KEYS*",  InterestResultPolicy.
*KEYS_VALUES*);


*Where OperationCacheListener is as follows:*

import java.util.Properties;

import com.gemstone.gemfire.cache.Declarable;
import com.gemstone.gemfire.cache.EntryEvent;
import com.gemstone.gemfire.cache.util.CacheListenerAdapter;

import org.eclipse.jetty.util.thread.ThreadPool;


public class OperationCacheListener extends CacheListenerAdapter implements
Declarable {

public void afterCreate(EntryEvent event) {


}


public void afterUpdate(EntryEvent event)

{


}

}


On Mon, May 23, 2016 at 8:00 PM, Ali Koyuncu <al...@gmail.com> wrote:

> Thank you!
> Let me check all of them, and let you know about the result.
>
> On Mon, May 23, 2016 at 7:52 PM, John Blum <jb...@pivotal.io> wrote:
>
>> An updated link Spring support for Apache Geode is here...
>>
>>
>> https://spring.io/blog/2016/04/29/spring-data-geode-1-0-0-apache-geode-incubating-m2-released
>>
>> Cheers!
>>
>> On Mon, May 23, 2016 at 9:48 AM, Udo Kohlmeyer <uk...@pivotal.io>
>> wrote:
>>
>>> Hi there Ali,
>>>
>>> In order to enable subscriptions on the client pool you need to set this
>>> property on your <pool> settings in your client's cache.xml file.
>>>
>>> Can you confirm that you have the following setup.
>>>
>>>    1. A running Locator and server(s)
>>>    2. A region set up on the server
>>>    3. A configured client using
>>>       1. Client cache.xml
>>>       2. the provided Java API
>>>       3. Using Spring Data Gemfire/Geode as described here
>>>       https://spring.io/blog/2015/06/12/spring-data-gemfire-supports-apache-geode
>>>    4. You have configured the "OperationRegion" on both your server and
>>>    client.
>>>
>>> --Udo
>>>
>>> On 24/05/2016 2:35 am, Ali Koyuncu wrote:
>>>
>>> Udo, hi,
>>>
>>> Here new questions come --- I am a newbie to Geode:
>>>
>>>
>>>    1. How to set "subscriptions-enabled=true" on the client pool? How
>>>    to enable subscription?
>>>    2. Do you have a sample code on events?
>>>
>>> Thanks.
>>>
>>> On Mon, May 23, 2016 at 7:28 PM, Udo Kohlmeyer <uk...@pivotal.io>
>>> wrote:
>>>
>>>> Hi there Ali,
>>>>
>>>> When you say "it does not fetch any event" do you mean you are
>>>> inserting/updating data entries on the server and the client does not get
>>>> notified? Or are you making changes on the client and not being notified?
>>>>
>>>> CacheListeners or CacheWriters should fire when you are making your
>>>> local region (in your case client).
>>>>
>>>> In order to have events propagated from the server to the client you
>>>> need to use "registerInterest" on your client region. This can be turned on:
>>>>
>>>>    1. enable subscriptions on your client pool, by setting
>>>>    "subscriptions-enabled=true"
>>>>    2. On the client region set
>>>>    "operationRegion.registerInterest("ALL_KEYS",
>>>>    InterestResultPolicy.KEYS_VALUES)
>>>>
>>>> After this any changes on the server will be propagated to your client.
>>>>
>>>> Is this the functionality you are looking for?
>>>>
>>>> --Udo
>>>> On 24/05/2016 2:00 am, Ali Koyuncu wrote:
>>>>
>>>> John,
>>>>
>>>> My code as as follows:
>>>>
>>>> this.listener = new OperationCacheListener();
>>>> this.OperationRegion = cache
>>>> .<String, iEvent>createClientRegionFactory(ClientRegionShortcut.PROXY)
>>>> .initCacheListeners(new CacheListener[]
>>>>    {this.listener})
>>>> .addCacheListener(this.listener)
>>>> .create(OperationRegionName);
>>>>
>>>>
>>>> where;
>>>>
>>>> private Region<String, iEvent> OperationRegion;
>>>>
>>>> private ClientCache cache;
>>>>
>>>> Despite I registered the listener, it doesn't fetch any event.
>>>>
>>>> Is the above code segment true?
>>>>
>>>> On Mon, May 23, 2016 at 6:49 PM, John Blum < <jb...@pivotal.io>
>>>> jblum@pivotal.io> wrote:
>>>>
>>>>> Hi Ali-
>>>>>
>>>>> You need to register the CacheListener on the *Region* in which the
>>>>> data access operations/entry events (gets/puts/etc) are taking place.  E.g.
>>>>> ...
>>>>>
>>>>> ClientRegionFactory operationRegionFactory =
>>>>> clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>>>>>
>>>>> *operationRegionFactory.addCacheListener(new
>>>>> OperationCacheListener());*
>>>>> operatonRegionFactory. ...
>>>>>
>>>>> Region operation = operationRegionFactory.create("Operation");
>>>>>
>>>>> -John
>>>>>
>>>>>
>>>>> On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu < <al...@gmail.com>
>>>>> ali.koyuncu@gmail.com> wrote:
>>>>>
>>>>>> Dear all,
>>>>>>
>>>>>> I created a region named Operation.
>>>>>>
>>>>>> What I want to do is to get notified upon creating or updating record
>>>>>> in this region.
>>>>>>
>>>>>> Following are my code segments:
>>>>>>
>>>>>> *Listener (named OperationCacheListener):*
>>>>>>
>>>>>>   public void afterCreate(EntryEvent event) {
>>>>>>
>>>>>>    iEvent message = (iEvent) event.getNewValue();
>>>>>>
>>>>>>    if(message instanceof CmdStartCSS)
>>>>>>    {
>>>>>>     logger.debug("[OperationCacheListener][Command: Start][Key:
>>>>>> {}]");
>>>>>>
>>>>>>     try {
>>>>>>     CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>>>>>>     DialManager.getInstance().Start(command);
>>>>>>     }
>>>>>>     catch(Exception e)
>>>>>>     {
>>>>>>     logger.error("[OperationCacheListener][Start][{}][Exception:
>>>>>> {}]", e.getClass().getSimpleName(), e.getMessage());
>>>>>>     }
>>>>>>
>>>>>>    }
>>>>>>    else if(message instanceof CmdStopCSS)
>>>>>>    {
>>>>>>     logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
>>>>>>     try {
>>>>>> DialManager.getInstance().Stop();
>>>>>> } catch (Exception e) {
>>>>>> //
>>>>>> }
>>>>>>    }
>>>>>>
>>>>>>   }
>>>>>>
>>>>>>   public void afterUpdate(EntryEvent event)
>>>>>>   {
>>>>>>  System.err.println("Region entry was updated.");
>>>>>>   }
>>>>>>
>>>>>>
>>>>>> *How I initiate the listener:*
>>>>>>
>>>>>> this.listener = new OperationCacheListener();
>>>>>> this.OperationRegion = cache
>>>>>> .<String,
>>>>>> iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>>>>>> .initCacheListeners(new CacheListener[]
>>>>>>    {this.listener})
>>>>>> .create(OperationRegionName);
>>>>>>
>>>>>>
>>>>>> *PROBLEM:*
>>>>>>
>>>>>> When I am to create/update a record in this region, my events are not
>>>>>> triggered.
>>>>>>
>>>>>> Could you please check and tell me where I am wrong or missing? (If
>>>>>> you have a sample code on this matter, I will be glad).
>>>>>>
>>>>>> Thank you in advance.
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> Saygılarımla, with my warm regards,
>>>>>>
>>>>>> Ali KOYUNCU
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> -John
>>>>> 503-504-8657
>>>>> john.blum10101 (skype)
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Saygılarımla, with my warm regards,
>>>>
>>>> Ali KOYUNCU
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>>
>>> Saygılarımla, with my warm regards,
>>>
>>> Ali KOYUNCU
>>>
>>>
>>>
>>
>>
>> --
>> -John
>> 503-504-8657
>> john.blum10101 (skype)
>>
>
>
>
> --
>
> Saygılarımla, with my warm regards,
>
> Ali KOYUNCU
>



-- 

Saygılarımla, with my warm regards,

Ali KOYUNCU

Re: Question about Region Events

Posted by Ali Koyuncu <al...@gmail.com>.
Thank you!
Let me check all of them, and let you know about the result.

On Mon, May 23, 2016 at 7:52 PM, John Blum <jb...@pivotal.io> wrote:

> An updated link Spring support for Apache Geode is here...
>
>
> https://spring.io/blog/2016/04/29/spring-data-geode-1-0-0-apache-geode-incubating-m2-released
>
> Cheers!
>
> On Mon, May 23, 2016 at 9:48 AM, Udo Kohlmeyer <uk...@pivotal.io>
> wrote:
>
>> Hi there Ali,
>>
>> In order to enable subscriptions on the client pool you need to set this
>> property on your <pool> settings in your client's cache.xml file.
>>
>> Can you confirm that you have the following setup.
>>
>>    1. A running Locator and server(s)
>>    2. A region set up on the server
>>    3. A configured client using
>>       1. Client cache.xml
>>       2. the provided Java API
>>       3. Using Spring Data Gemfire/Geode as described here
>>       https://spring.io/blog/2015/06/12/spring-data-gemfire-supports-apache-geode
>>    4. You have configured the "OperationRegion" on both your server and
>>    client.
>>
>> --Udo
>>
>> On 24/05/2016 2:35 am, Ali Koyuncu wrote:
>>
>> Udo, hi,
>>
>> Here new questions come --- I am a newbie to Geode:
>>
>>
>>    1. How to set "subscriptions-enabled=true" on the client pool? How to
>>    enable subscription?
>>    2. Do you have a sample code on events?
>>
>> Thanks.
>>
>> On Mon, May 23, 2016 at 7:28 PM, Udo Kohlmeyer <uk...@pivotal.io>
>> wrote:
>>
>>> Hi there Ali,
>>>
>>> When you say "it does not fetch any event" do you mean you are
>>> inserting/updating data entries on the server and the client does not get
>>> notified? Or are you making changes on the client and not being notified?
>>>
>>> CacheListeners or CacheWriters should fire when you are making your
>>> local region (in your case client).
>>>
>>> In order to have events propagated from the server to the client you
>>> need to use "registerInterest" on your client region. This can be turned on:
>>>
>>>    1. enable subscriptions on your client pool, by setting
>>>    "subscriptions-enabled=true"
>>>    2. On the client region set
>>>    "operationRegion.registerInterest("ALL_KEYS",
>>>    InterestResultPolicy.KEYS_VALUES)
>>>
>>> After this any changes on the server will be propagated to your client.
>>>
>>> Is this the functionality you are looking for?
>>>
>>> --Udo
>>> On 24/05/2016 2:00 am, Ali Koyuncu wrote:
>>>
>>> John,
>>>
>>> My code as as follows:
>>>
>>> this.listener = new OperationCacheListener();
>>> this.OperationRegion = cache
>>> .<String, iEvent>createClientRegionFactory(ClientRegionShortcut.PROXY)
>>> .initCacheListeners(new CacheListener[]
>>>    {this.listener})
>>> .addCacheListener(this.listener)
>>> .create(OperationRegionName);
>>>
>>>
>>> where;
>>>
>>> private Region<String, iEvent> OperationRegion;
>>>
>>> private ClientCache cache;
>>>
>>> Despite I registered the listener, it doesn't fetch any event.
>>>
>>> Is the above code segment true?
>>>
>>> On Mon, May 23, 2016 at 6:49 PM, John Blum < <jb...@pivotal.io>
>>> jblum@pivotal.io> wrote:
>>>
>>>> Hi Ali-
>>>>
>>>> You need to register the CacheListener on the *Region* in which the
>>>> data access operations/entry events (gets/puts/etc) are taking place.  E.g.
>>>> ...
>>>>
>>>> ClientRegionFactory operationRegionFactory =
>>>> clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>>>>
>>>> *operationRegionFactory.addCacheListener(new OperationCacheListener());*
>>>> operatonRegionFactory. ...
>>>>
>>>> Region operation = operationRegionFactory.create("Operation");
>>>>
>>>> -John
>>>>
>>>>
>>>> On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu < <al...@gmail.com>
>>>> ali.koyuncu@gmail.com> wrote:
>>>>
>>>>> Dear all,
>>>>>
>>>>> I created a region named Operation.
>>>>>
>>>>> What I want to do is to get notified upon creating or updating record
>>>>> in this region.
>>>>>
>>>>> Following are my code segments:
>>>>>
>>>>> *Listener (named OperationCacheListener):*
>>>>>
>>>>>   public void afterCreate(EntryEvent event) {
>>>>>
>>>>>    iEvent message = (iEvent) event.getNewValue();
>>>>>
>>>>>    if(message instanceof CmdStartCSS)
>>>>>    {
>>>>>     logger.debug("[OperationCacheListener][Command: Start][Key: {}]");
>>>>>
>>>>>     try {
>>>>>     CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>>>>>     DialManager.getInstance().Start(command);
>>>>>     }
>>>>>     catch(Exception e)
>>>>>     {
>>>>>     logger.error("[OperationCacheListener][Start][{}][Exception:
>>>>> {}]", e.getClass().getSimpleName(), e.getMessage());
>>>>>     }
>>>>>
>>>>>    }
>>>>>    else if(message instanceof CmdStopCSS)
>>>>>    {
>>>>>     logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
>>>>>     try {
>>>>> DialManager.getInstance().Stop();
>>>>> } catch (Exception e) {
>>>>> //
>>>>> }
>>>>>    }
>>>>>
>>>>>   }
>>>>>
>>>>>   public void afterUpdate(EntryEvent event)
>>>>>   {
>>>>>  System.err.println("Region entry was updated.");
>>>>>   }
>>>>>
>>>>>
>>>>> *How I initiate the listener:*
>>>>>
>>>>> this.listener = new OperationCacheListener();
>>>>> this.OperationRegion = cache
>>>>> .<String,
>>>>> iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>>>>> .initCacheListeners(new CacheListener[]
>>>>>    {this.listener})
>>>>> .create(OperationRegionName);
>>>>>
>>>>>
>>>>> *PROBLEM:*
>>>>>
>>>>> When I am to create/update a record in this region, my events are not
>>>>> triggered.
>>>>>
>>>>> Could you please check and tell me where I am wrong or missing? (If
>>>>> you have a sample code on this matter, I will be glad).
>>>>>
>>>>> Thank you in advance.
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> Saygılarımla, with my warm regards,
>>>>>
>>>>> Ali KOYUNCU
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> -John
>>>> 503-504-8657
>>>> john.blum10101 (skype)
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> Saygılarımla, with my warm regards,
>>>
>>> Ali KOYUNCU
>>>
>>>
>>>
>>
>>
>> --
>>
>> Saygılarımla, with my warm regards,
>>
>> Ali KOYUNCU
>>
>>
>>
>
>
> --
> -John
> 503-504-8657
> john.blum10101 (skype)
>



-- 

Saygılarımla, with my warm regards,

Ali KOYUNCU

Re: Question about Region Events

Posted by John Blum <jb...@pivotal.io>.
An updated link Spring support for Apache Geode is here...

https://spring.io/blog/2016/04/29/spring-data-geode-1-0-0-apache-geode-incubating-m2-released

Cheers!

On Mon, May 23, 2016 at 9:48 AM, Udo Kohlmeyer <uk...@pivotal.io>
wrote:

> Hi there Ali,
>
> In order to enable subscriptions on the client pool you need to set this
> property on your <pool> settings in your client's cache.xml file.
>
> Can you confirm that you have the following setup.
>
>    1. A running Locator and server(s)
>    2. A region set up on the server
>    3. A configured client using
>       1. Client cache.xml
>       2. the provided Java API
>       3. Using Spring Data Gemfire/Geode as described here
>       https://spring.io/blog/2015/06/12/spring-data-gemfire-supports-apache-geode
>    4. You have configured the "OperationRegion" on both your server and
>    client.
>
> --Udo
>
> On 24/05/2016 2:35 am, Ali Koyuncu wrote:
>
> Udo, hi,
>
> Here new questions come --- I am a newbie to Geode:
>
>
>    1. How to set "subscriptions-enabled=true" on the client pool? How to
>    enable subscription?
>    2. Do you have a sample code on events?
>
> Thanks.
>
> On Mon, May 23, 2016 at 7:28 PM, Udo Kohlmeyer <uk...@pivotal.io>
> wrote:
>
>> Hi there Ali,
>>
>> When you say "it does not fetch any event" do you mean you are
>> inserting/updating data entries on the server and the client does not get
>> notified? Or are you making changes on the client and not being notified?
>>
>> CacheListeners or CacheWriters should fire when you are making your local
>> region (in your case client).
>>
>> In order to have events propagated from the server to the client you need
>> to use "registerInterest" on your client region. This can be turned on:
>>
>>    1. enable subscriptions on your client pool, by setting
>>    "subscriptions-enabled=true"
>>    2. On the client region set
>>    "operationRegion.registerInterest("ALL_KEYS",
>>    InterestResultPolicy.KEYS_VALUES)
>>
>> After this any changes on the server will be propagated to your client.
>>
>> Is this the functionality you are looking for?
>>
>> --Udo
>> On 24/05/2016 2:00 am, Ali Koyuncu wrote:
>>
>> John,
>>
>> My code as as follows:
>>
>> this.listener = new OperationCacheListener();
>> this.OperationRegion = cache
>> .<String, iEvent>createClientRegionFactory(ClientRegionShortcut.PROXY)
>> .initCacheListeners(new CacheListener[]
>>    {this.listener})
>> .addCacheListener(this.listener)
>> .create(OperationRegionName);
>>
>>
>> where;
>>
>> private Region<String, iEvent> OperationRegion;
>>
>> private ClientCache cache;
>>
>> Despite I registered the listener, it doesn't fetch any event.
>>
>> Is the above code segment true?
>>
>> On Mon, May 23, 2016 at 6:49 PM, John Blum < <jb...@pivotal.io>
>> jblum@pivotal.io> wrote:
>>
>>> Hi Ali-
>>>
>>> You need to register the CacheListener on the *Region* in which the
>>> data access operations/entry events (gets/puts/etc) are taking place.  E.g.
>>> ...
>>>
>>> ClientRegionFactory operationRegionFactory =
>>> clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>>>
>>> *operationRegionFactory.addCacheListener(new OperationCacheListener());*
>>> operatonRegionFactory. ...
>>>
>>> Region operation = operationRegionFactory.create("Operation");
>>>
>>> -John
>>>
>>>
>>> On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu < <al...@gmail.com>
>>> ali.koyuncu@gmail.com> wrote:
>>>
>>>> Dear all,
>>>>
>>>> I created a region named Operation.
>>>>
>>>> What I want to do is to get notified upon creating or updating record
>>>> in this region.
>>>>
>>>> Following are my code segments:
>>>>
>>>> *Listener (named OperationCacheListener):*
>>>>
>>>>   public void afterCreate(EntryEvent event) {
>>>>
>>>>    iEvent message = (iEvent) event.getNewValue();
>>>>
>>>>    if(message instanceof CmdStartCSS)
>>>>    {
>>>>     logger.debug("[OperationCacheListener][Command: Start][Key: {}]");
>>>>
>>>>     try {
>>>>     CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>>>>     DialManager.getInstance().Start(command);
>>>>     }
>>>>     catch(Exception e)
>>>>     {
>>>>     logger.error("[OperationCacheListener][Start][{}][Exception: {}]",
>>>> e.getClass().getSimpleName(), e.getMessage());
>>>>     }
>>>>
>>>>    }
>>>>    else if(message instanceof CmdStopCSS)
>>>>    {
>>>>     logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
>>>>     try {
>>>> DialManager.getInstance().Stop();
>>>> } catch (Exception e) {
>>>> //
>>>> }
>>>>    }
>>>>
>>>>   }
>>>>
>>>>   public void afterUpdate(EntryEvent event)
>>>>   {
>>>>  System.err.println("Region entry was updated.");
>>>>   }
>>>>
>>>>
>>>> *How I initiate the listener:*
>>>>
>>>> this.listener = new OperationCacheListener();
>>>> this.OperationRegion = cache
>>>> .<String,
>>>> iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>>>> .initCacheListeners(new CacheListener[]
>>>>    {this.listener})
>>>> .create(OperationRegionName);
>>>>
>>>>
>>>> *PROBLEM:*
>>>>
>>>> When I am to create/update a record in this region, my events are not
>>>> triggered.
>>>>
>>>> Could you please check and tell me where I am wrong or missing? (If you
>>>> have a sample code on this matter, I will be glad).
>>>>
>>>> Thank you in advance.
>>>>
>>>>
>>>> --
>>>>
>>>> Saygılarımla, with my warm regards,
>>>>
>>>> Ali KOYUNCU
>>>>
>>>
>>>
>>>
>>> --
>>> -John
>>> 503-504-8657
>>> john.blum10101 (skype)
>>>
>>
>>
>>
>> --
>>
>> Saygılarımla, with my warm regards,
>>
>> Ali KOYUNCU
>>
>>
>>
>
>
> --
>
> Saygılarımla, with my warm regards,
>
> Ali KOYUNCU
>
>
>


-- 
-John
503-504-8657
john.blum10101 (skype)

Re: Question about Region Events

Posted by Udo Kohlmeyer <uk...@pivotal.io>.
Hi there Ali,

In order to enable subscriptions on the client pool you need to set this 
property on your <pool> settings in your client's cache.xml file.

Can you confirm that you have the following setup.

 1. A running Locator and server(s)
 2. A region set up on the server
 3. A configured client using
     1. Client cache.xml
     2. the provided Java API
     3. Using Spring Data Gemfire/Geode as described here
        https://spring.io/blog/2015/06/12/spring-data-gemfire-supports-apache-geode
 4. You have configured the "OperationRegion" on both your server and
    client.

--Udo


On 24/05/2016 2:35 am, Ali Koyuncu wrote:
> Udo, hi,
>
> Here new questions come --- I am a newbie to Geode:
>
>  1. How to set "subscriptions-enabled=true" on the client pool? How to
>     enable subscription?
>  2. Do you have a sample code on events?
>
> Thanks.
>
> On Mon, May 23, 2016 at 7:28 PM, Udo Kohlmeyer <ukohlmeyer@pivotal.io 
> <ma...@pivotal.io>> wrote:
>
>     Hi there Ali,
>
>     When you say "it does not fetch any event" do you mean you are
>     inserting/updating data entries on the server and the client does
>     not get notified? Or are you making changes on the client and not
>     being notified?
>
>     CacheListeners or CacheWriters should fire when you are making
>     your local region (in your case client).
>
>     In order to have events propagated from the server to the client
>     you need to use "registerInterest" on your client region. This can
>     be turned on:
>
>      1. enable subscriptions on your client pool, by setting
>         "subscriptions-enabled=true"
>      2. On the client region set
>         "operationRegion.registerInterest("ALL_KEYS",
>         InterestResultPolicy.KEYS_VALUES)
>
>     After this any changes on the server will be propagated to your
>     client.
>
>     Is this the functionality you are looking for?
>
>     --Udo
>
>     On 24/05/2016 2:00 am, Ali Koyuncu wrote:
>>     John,
>>
>>     My code as as follows:
>>
>>     this.listener = new OperationCacheListener();
>>     this.OperationRegion = cache
>>     .<String,
>>     iEvent>createClientRegionFactory(ClientRegionShortcut.PROXY)
>>     .initCacheListeners(new CacheListener[]
>>        {this.listener})
>>     .addCacheListener(this.listener)
>>     .create(OperationRegionName);
>>
>>
>>     where;
>>
>>     private Region<String, iEvent> OperationRegion;
>>
>>     privateClientCache cache;
>>
>>     Despite I registered the listener, it doesn't fetch any event.
>>
>>     Is the above code segment true?
>>
>>     On Mon, May 23, 2016 at 6:49 PM, John Blum <jblum@pivotal.io
>>     <ma...@pivotal.io>> wrote:
>>
>>         Hi Ali-
>>
>>         You need to register the CacheListener on the /Region/ in
>>         which the data access operations/entry events (gets/puts/etc)
>>         are taking place.  E.g. ...
>>
>>         ClientRegionFactory operationRegionFactory =
>>         clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>>
>>         *operationRegionFactory.addCacheListener(new
>>         OperationCacheListener());*
>>         operatonRegionFactory. ...
>>
>>         Region operation = operationRegionFactory.create("Operation");
>>
>>         -John
>>
>>
>>         On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu
>>         <ali.koyuncu@gmail.com <ma...@gmail.com>> wrote:
>>
>>             Dear all,
>>
>>             I created a region named Operation.
>>
>>             What I want to do is to get notified upon creating or
>>             updating record in this region.
>>
>>             Following are my code segments:
>>
>>             *Listener (named /OperationCacheListener/):*
>>             *
>>             *
>>             **public void afterCreate(EntryEvent event) {
>>                iEvent message = (iEvent) event.getNewValue();
>>                if(message instanceof CmdStartCSS)
>>                {
>>             logger.debug("[OperationCacheListener][Command:
>>             Start][Key: {}]");
>>             try {
>>             CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>>             DialManager.getInstance().Start(command);
>>             }
>>             catch(Exception e)
>>             {
>>             logger.error("[OperationCacheListener][Start][{}][Exception:
>>             {}]", e.getClass().getSimpleName(), e.getMessage());
>>             }
>>                }
>>                else if(message instanceof CmdStopCSS)
>>                {
>>             logger.debug("[OperationCacheListener][Command:
>>             Stop][Key: {}]");
>>             try {
>>             DialManager.getInstance().Stop();
>>             } catch (Exception e) {
>>             //
>>             }
>>                }
>>               }
>>               public void afterUpdate(EntryEvent event)
>>               {
>>              System.err.println("Region entry was updated.");
>>               }
>>             *
>>             *
>>             *
>>             *
>>             *How I initiate the listener:*
>>             *
>>             *
>>             this.listener = new OperationCacheListener();
>>             this.OperationRegion = cache
>>             .<String,
>>             iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>>             .initCacheListeners(new CacheListener[]
>>                {this.listener})
>>             .create(OperationRegionName);
>>
>>
>>             *PROBLEM:*
>>             *
>>             *
>>             When I am to create/update a record in this region, my
>>             events are not triggered.
>>
>>             Could you please check and tell me where I am wrong or
>>             missing? (If you have a sample code on this matter, I
>>             will be glad).
>>
>>             Thank you in advance.
>>
>>             -- 
>>
>>             Sayg\u0131lar\u0131mla, with my warm regards,
>>
>>             Ali KOYUNCU
>>
>>
>>
>>
>>         -- 
>>         -John
>>         503-504-8657 <tel:503-504-8657>
>>         john.blum10101 (skype)
>>
>>
>>
>>
>>     -- 
>>
>>     Sayg\u0131lar\u0131mla, with my warm regards,
>>
>>     Ali KOYUNCU
>
>
>
>
> -- 
>
> Sayg\u0131lar\u0131mla, with my warm regards,
>
> Ali KOYUNCU


Re: Question about Region Events

Posted by Jianxia Chen <jc...@pivotal.io>.
Should have sent you this Geode document instead of GemFire document, but
they are essentially the same:

http://geode.docs.pivotal.io/docs/developing/events/configure_client_server_event_messaging.html

On Mon, May 23, 2016 at 9:41 AM, Jianxia Chen <jc...@pivotal.io> wrote:

> Hi Ali,
>
> Here is the document:
>
>
> http://gemfire.docs.pivotal.io/docs-gemfire/latest/developing/events/configure_client_server_event_messaging.html
>
> Thanks,
> Jianxia
>
> On Mon, May 23, 2016 at 9:35 AM, Ali Koyuncu <al...@gmail.com>
> wrote:
>
>> Udo, hi,
>>
>> Here new questions come --- I am a newbie to Geode:
>>
>>
>>    1. How to set "subscriptions-enabled=true" on the client pool? How to
>>    enable subscription?
>>    2. Do you have a sample code on events?
>>
>> Thanks.
>>
>> On Mon, May 23, 2016 at 7:28 PM, Udo Kohlmeyer <uk...@pivotal.io>
>> wrote:
>>
>>> Hi there Ali,
>>>
>>> When you say "it does not fetch any event" do you mean you are
>>> inserting/updating data entries on the server and the client does not get
>>> notified? Or are you making changes on the client and not being notified?
>>>
>>> CacheListeners or CacheWriters should fire when you are making your
>>> local region (in your case client).
>>>
>>> In order to have events propagated from the server to the client you
>>> need to use "registerInterest" on your client region. This can be turned on:
>>>
>>>    1. enable subscriptions on your client pool, by setting
>>>    "subscriptions-enabled=true"
>>>    2. On the client region set
>>>    "operationRegion.registerInterest("ALL_KEYS",
>>>    InterestResultPolicy.KEYS_VALUES)
>>>
>>> After this any changes on the server will be propagated to your client.
>>>
>>> Is this the functionality you are looking for?
>>>
>>> --Udo
>>> On 24/05/2016 2:00 am, Ali Koyuncu wrote:
>>>
>>> John,
>>>
>>> My code as as follows:
>>>
>>> this.listener = new OperationCacheListener();
>>> this.OperationRegion = cache
>>> .<String, iEvent>createClientRegionFactory(ClientRegionShortcut.PROXY)
>>> .initCacheListeners(new CacheListener[]
>>>    {this.listener})
>>> .addCacheListener(this.listener)
>>> .create(OperationRegionName);
>>>
>>>
>>> where;
>>>
>>> private Region<String, iEvent> OperationRegion;
>>>
>>> private ClientCache cache;
>>>
>>> Despite I registered the listener, it doesn't fetch any event.
>>>
>>> Is the above code segment true?
>>>
>>> On Mon, May 23, 2016 at 6:49 PM, John Blum <jb...@pivotal.io> wrote:
>>>
>>>> Hi Ali-
>>>>
>>>> You need to register the CacheListener on the *Region* in which the
>>>> data access operations/entry events (gets/puts/etc) are taking place.  E.g.
>>>> ...
>>>>
>>>> ClientRegionFactory operationRegionFactory =
>>>> clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>>>>
>>>> *operationRegionFactory.addCacheListener(new OperationCacheListener());*
>>>> operatonRegionFactory. ...
>>>>
>>>> Region operation = operationRegionFactory.create("Operation");
>>>>
>>>> -John
>>>>
>>>>
>>>> On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu < <al...@gmail.com>
>>>> ali.koyuncu@gmail.com> wrote:
>>>>
>>>>> Dear all,
>>>>>
>>>>> I created a region named Operation.
>>>>>
>>>>> What I want to do is to get notified upon creating or updating record
>>>>> in this region.
>>>>>
>>>>> Following are my code segments:
>>>>>
>>>>> *Listener (named OperationCacheListener):*
>>>>>
>>>>>   public void afterCreate(EntryEvent event) {
>>>>>
>>>>>    iEvent message = (iEvent) event.getNewValue();
>>>>>
>>>>>    if(message instanceof CmdStartCSS)
>>>>>    {
>>>>>     logger.debug("[OperationCacheListener][Command: Start][Key: {}]");
>>>>>
>>>>>     try {
>>>>>     CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>>>>>     DialManager.getInstance().Start(command);
>>>>>     }
>>>>>     catch(Exception e)
>>>>>     {
>>>>>     logger.error("[OperationCacheListener][Start][{}][Exception:
>>>>> {}]", e.getClass().getSimpleName(), e.getMessage());
>>>>>     }
>>>>>
>>>>>    }
>>>>>    else if(message instanceof CmdStopCSS)
>>>>>    {
>>>>>     logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
>>>>>     try {
>>>>> DialManager.getInstance().Stop();
>>>>> } catch (Exception e) {
>>>>> //
>>>>> }
>>>>>    }
>>>>>
>>>>>   }
>>>>>
>>>>>   public void afterUpdate(EntryEvent event)
>>>>>   {
>>>>>  System.err.println("Region entry was updated.");
>>>>>   }
>>>>>
>>>>>
>>>>> *How I initiate the listener:*
>>>>>
>>>>> this.listener = new OperationCacheListener();
>>>>> this.OperationRegion = cache
>>>>> .<String,
>>>>> iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>>>>> .initCacheListeners(new CacheListener[]
>>>>>    {this.listener})
>>>>> .create(OperationRegionName);
>>>>>
>>>>>
>>>>> *PROBLEM:*
>>>>>
>>>>> When I am to create/update a record in this region, my events are not
>>>>> triggered.
>>>>>
>>>>> Could you please check and tell me where I am wrong or missing? (If
>>>>> you have a sample code on this matter, I will be glad).
>>>>>
>>>>> Thank you in advance.
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> Saygılarımla, with my warm regards,
>>>>>
>>>>> Ali KOYUNCU
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> -John
>>>> 503-504-8657
>>>> john.blum10101 (skype)
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> Saygılarımla, with my warm regards,
>>>
>>> Ali KOYUNCU
>>>
>>>
>>>
>>
>>
>> --
>>
>> Saygılarımla, with my warm regards,
>>
>> Ali KOYUNCU
>>
>
>

Re: Question about Region Events

Posted by Jianxia Chen <jc...@pivotal.io>.
Hi Ali,

Here is the document:

http://gemfire.docs.pivotal.io/docs-gemfire/latest/developing/events/configure_client_server_event_messaging.html

Thanks,
Jianxia

On Mon, May 23, 2016 at 9:35 AM, Ali Koyuncu <al...@gmail.com> wrote:

> Udo, hi,
>
> Here new questions come --- I am a newbie to Geode:
>
>
>    1. How to set "subscriptions-enabled=true" on the client pool? How to
>    enable subscription?
>    2. Do you have a sample code on events?
>
> Thanks.
>
> On Mon, May 23, 2016 at 7:28 PM, Udo Kohlmeyer <uk...@pivotal.io>
> wrote:
>
>> Hi there Ali,
>>
>> When you say "it does not fetch any event" do you mean you are
>> inserting/updating data entries on the server and the client does not get
>> notified? Or are you making changes on the client and not being notified?
>>
>> CacheListeners or CacheWriters should fire when you are making your local
>> region (in your case client).
>>
>> In order to have events propagated from the server to the client you need
>> to use "registerInterest" on your client region. This can be turned on:
>>
>>    1. enable subscriptions on your client pool, by setting
>>    "subscriptions-enabled=true"
>>    2. On the client region set
>>    "operationRegion.registerInterest("ALL_KEYS",
>>    InterestResultPolicy.KEYS_VALUES)
>>
>> After this any changes on the server will be propagated to your client.
>>
>> Is this the functionality you are looking for?
>>
>> --Udo
>> On 24/05/2016 2:00 am, Ali Koyuncu wrote:
>>
>> John,
>>
>> My code as as follows:
>>
>> this.listener = new OperationCacheListener();
>> this.OperationRegion = cache
>> .<String, iEvent>createClientRegionFactory(ClientRegionShortcut.PROXY)
>> .initCacheListeners(new CacheListener[]
>>    {this.listener})
>> .addCacheListener(this.listener)
>> .create(OperationRegionName);
>>
>>
>> where;
>>
>> private Region<String, iEvent> OperationRegion;
>>
>> private ClientCache cache;
>>
>> Despite I registered the listener, it doesn't fetch any event.
>>
>> Is the above code segment true?
>>
>> On Mon, May 23, 2016 at 6:49 PM, John Blum <jb...@pivotal.io> wrote:
>>
>>> Hi Ali-
>>>
>>> You need to register the CacheListener on the *Region* in which the
>>> data access operations/entry events (gets/puts/etc) are taking place.  E.g.
>>> ...
>>>
>>> ClientRegionFactory operationRegionFactory =
>>> clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>>>
>>> *operationRegionFactory.addCacheListener(new OperationCacheListener());*
>>> operatonRegionFactory. ...
>>>
>>> Region operation = operationRegionFactory.create("Operation");
>>>
>>> -John
>>>
>>>
>>> On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu < <al...@gmail.com>
>>> ali.koyuncu@gmail.com> wrote:
>>>
>>>> Dear all,
>>>>
>>>> I created a region named Operation.
>>>>
>>>> What I want to do is to get notified upon creating or updating record
>>>> in this region.
>>>>
>>>> Following are my code segments:
>>>>
>>>> *Listener (named OperationCacheListener):*
>>>>
>>>>   public void afterCreate(EntryEvent event) {
>>>>
>>>>    iEvent message = (iEvent) event.getNewValue();
>>>>
>>>>    if(message instanceof CmdStartCSS)
>>>>    {
>>>>     logger.debug("[OperationCacheListener][Command: Start][Key: {}]");
>>>>
>>>>     try {
>>>>     CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>>>>     DialManager.getInstance().Start(command);
>>>>     }
>>>>     catch(Exception e)
>>>>     {
>>>>     logger.error("[OperationCacheListener][Start][{}][Exception: {}]",
>>>> e.getClass().getSimpleName(), e.getMessage());
>>>>     }
>>>>
>>>>    }
>>>>    else if(message instanceof CmdStopCSS)
>>>>    {
>>>>     logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
>>>>     try {
>>>> DialManager.getInstance().Stop();
>>>> } catch (Exception e) {
>>>> //
>>>> }
>>>>    }
>>>>
>>>>   }
>>>>
>>>>   public void afterUpdate(EntryEvent event)
>>>>   {
>>>>  System.err.println("Region entry was updated.");
>>>>   }
>>>>
>>>>
>>>> *How I initiate the listener:*
>>>>
>>>> this.listener = new OperationCacheListener();
>>>> this.OperationRegion = cache
>>>> .<String,
>>>> iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>>>> .initCacheListeners(new CacheListener[]
>>>>    {this.listener})
>>>> .create(OperationRegionName);
>>>>
>>>>
>>>> *PROBLEM:*
>>>>
>>>> When I am to create/update a record in this region, my events are not
>>>> triggered.
>>>>
>>>> Could you please check and tell me where I am wrong or missing? (If you
>>>> have a sample code on this matter, I will be glad).
>>>>
>>>> Thank you in advance.
>>>>
>>>>
>>>> --
>>>>
>>>> Saygılarımla, with my warm regards,
>>>>
>>>> Ali KOYUNCU
>>>>
>>>
>>>
>>>
>>> --
>>> -John
>>> 503-504-8657
>>> john.blum10101 (skype)
>>>
>>
>>
>>
>> --
>>
>> Saygılarımla, with my warm regards,
>>
>> Ali KOYUNCU
>>
>>
>>
>
>
> --
>
> Saygılarımla, with my warm regards,
>
> Ali KOYUNCU
>

Re: Question about Region Events

Posted by John Blum <jb...@pivotal.io>.
Hi Ali-

See...
http://data-docs-samples.cfapps.io/docs-gemfire/latest/javadocs/japi/com/gemstone/gemfire/cache/client/ClientCacheFactory.html#setPoolSubscriptionEnabled(boolean)

Then this...
http://data-docs-samples.cfapps.io/docs-gemfire/latest/javadocs/japi/com/gemstone/gemfire/cache/Region.html

And specifically search for all the registerInterestXXXX(..) methods, e.g.
http://data-docs-samples.cfapps.io/docs-gemfire/latest/javadocs/japi/com/gemstone/gemfire/cache/Region.html#registerInterestRegex(java.lang.String,%20com.gemstone.gemfire.cache.InterestResultPolicy,%20boolean,%20boolean)



On Mon, May 23, 2016 at 9:35 AM, Ali Koyuncu <al...@gmail.com> wrote:

> Udo, hi,
>
> Here new questions come --- I am a newbie to Geode:
>
>
>    1. How to set "subscriptions-enabled=true" on the client pool? How to
>    enable subscription?
>    2. Do you have a sample code on events?
>
> Thanks.
>
> On Mon, May 23, 2016 at 7:28 PM, Udo Kohlmeyer <uk...@pivotal.io>
> wrote:
>
>> Hi there Ali,
>>
>> When you say "it does not fetch any event" do you mean you are
>> inserting/updating data entries on the server and the client does not get
>> notified? Or are you making changes on the client and not being notified?
>>
>> CacheListeners or CacheWriters should fire when you are making your local
>> region (in your case client).
>>
>> In order to have events propagated from the server to the client you need
>> to use "registerInterest" on your client region. This can be turned on:
>>
>>    1. enable subscriptions on your client pool, by setting
>>    "subscriptions-enabled=true"
>>    2. On the client region set
>>    "operationRegion.registerInterest("ALL_KEYS",
>>    InterestResultPolicy.KEYS_VALUES)
>>
>> After this any changes on the server will be propagated to your client.
>>
>> Is this the functionality you are looking for?
>>
>> --Udo
>> On 24/05/2016 2:00 am, Ali Koyuncu wrote:
>>
>> John,
>>
>> My code as as follows:
>>
>> this.listener = new OperationCacheListener();
>> this.OperationRegion = cache
>> .<String, iEvent>createClientRegionFactory(ClientRegionShortcut.PROXY)
>> .initCacheListeners(new CacheListener[]
>>    {this.listener})
>> .addCacheListener(this.listener)
>> .create(OperationRegionName);
>>
>>
>> where;
>>
>> private Region<String, iEvent> OperationRegion;
>>
>> private ClientCache cache;
>>
>> Despite I registered the listener, it doesn't fetch any event.
>>
>> Is the above code segment true?
>>
>> On Mon, May 23, 2016 at 6:49 PM, John Blum <jb...@pivotal.io> wrote:
>>
>>> Hi Ali-
>>>
>>> You need to register the CacheListener on the *Region* in which the
>>> data access operations/entry events (gets/puts/etc) are taking place.  E.g.
>>> ...
>>>
>>> ClientRegionFactory operationRegionFactory =
>>> clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>>>
>>> *operationRegionFactory.addCacheListener(new OperationCacheListener());*
>>> operatonRegionFactory. ...
>>>
>>> Region operation = operationRegionFactory.create("Operation");
>>>
>>> -John
>>>
>>>
>>> On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu < <al...@gmail.com>
>>> ali.koyuncu@gmail.com> wrote:
>>>
>>>> Dear all,
>>>>
>>>> I created a region named Operation.
>>>>
>>>> What I want to do is to get notified upon creating or updating record
>>>> in this region.
>>>>
>>>> Following are my code segments:
>>>>
>>>> *Listener (named OperationCacheListener):*
>>>>
>>>>   public void afterCreate(EntryEvent event) {
>>>>
>>>>    iEvent message = (iEvent) event.getNewValue();
>>>>
>>>>    if(message instanceof CmdStartCSS)
>>>>    {
>>>>     logger.debug("[OperationCacheListener][Command: Start][Key: {}]");
>>>>
>>>>     try {
>>>>     CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>>>>     DialManager.getInstance().Start(command);
>>>>     }
>>>>     catch(Exception e)
>>>>     {
>>>>     logger.error("[OperationCacheListener][Start][{}][Exception: {}]",
>>>> e.getClass().getSimpleName(), e.getMessage());
>>>>     }
>>>>
>>>>    }
>>>>    else if(message instanceof CmdStopCSS)
>>>>    {
>>>>     logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
>>>>     try {
>>>> DialManager.getInstance().Stop();
>>>> } catch (Exception e) {
>>>> //
>>>> }
>>>>    }
>>>>
>>>>   }
>>>>
>>>>   public void afterUpdate(EntryEvent event)
>>>>   {
>>>>  System.err.println("Region entry was updated.");
>>>>   }
>>>>
>>>>
>>>> *How I initiate the listener:*
>>>>
>>>> this.listener = new OperationCacheListener();
>>>> this.OperationRegion = cache
>>>> .<String,
>>>> iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>>>> .initCacheListeners(new CacheListener[]
>>>>    {this.listener})
>>>> .create(OperationRegionName);
>>>>
>>>>
>>>> *PROBLEM:*
>>>>
>>>> When I am to create/update a record in this region, my events are not
>>>> triggered.
>>>>
>>>> Could you please check and tell me where I am wrong or missing? (If you
>>>> have a sample code on this matter, I will be glad).
>>>>
>>>> Thank you in advance.
>>>>
>>>>
>>>> --
>>>>
>>>> Saygılarımla, with my warm regards,
>>>>
>>>> Ali KOYUNCU
>>>>
>>>
>>>
>>>
>>> --
>>> -John
>>> 503-504-8657
>>> john.blum10101 (skype)
>>>
>>
>>
>>
>> --
>>
>> Saygılarımla, with my warm regards,
>>
>> Ali KOYUNCU
>>
>>
>>
>
>
> --
>
> Saygılarımla, with my warm regards,
>
> Ali KOYUNCU
>



-- 
-John
503-504-8657
john.blum10101 (skype)

Re: Question about Region Events

Posted by Ali Koyuncu <al...@gmail.com>.
Udo, hi,

Here new questions come --- I am a newbie to Geode:


   1. How to set "subscriptions-enabled=true" on the client pool? How to
   enable subscription?
   2. Do you have a sample code on events?

Thanks.

On Mon, May 23, 2016 at 7:28 PM, Udo Kohlmeyer <uk...@pivotal.io>
wrote:

> Hi there Ali,
>
> When you say "it does not fetch any event" do you mean you are
> inserting/updating data entries on the server and the client does not get
> notified? Or are you making changes on the client and not being notified?
>
> CacheListeners or CacheWriters should fire when you are making your local
> region (in your case client).
>
> In order to have events propagated from the server to the client you need
> to use "registerInterest" on your client region. This can be turned on:
>
>    1. enable subscriptions on your client pool, by setting
>    "subscriptions-enabled=true"
>    2. On the client region set
>    "operationRegion.registerInterest("ALL_KEYS",
>    InterestResultPolicy.KEYS_VALUES)
>
> After this any changes on the server will be propagated to your client.
>
> Is this the functionality you are looking for?
>
> --Udo
> On 24/05/2016 2:00 am, Ali Koyuncu wrote:
>
> John,
>
> My code as as follows:
>
> this.listener = new OperationCacheListener();
> this.OperationRegion = cache
> .<String, iEvent>createClientRegionFactory(ClientRegionShortcut.PROXY)
> .initCacheListeners(new CacheListener[]
>    {this.listener})
> .addCacheListener(this.listener)
> .create(OperationRegionName);
>
>
> where;
>
> private Region<String, iEvent> OperationRegion;
>
> private ClientCache cache;
>
> Despite I registered the listener, it doesn't fetch any event.
>
> Is the above code segment true?
>
> On Mon, May 23, 2016 at 6:49 PM, John Blum <jb...@pivotal.io> wrote:
>
>> Hi Ali-
>>
>> You need to register the CacheListener on the *Region* in which the data
>> access operations/entry events (gets/puts/etc) are taking place.  E.g. ...
>>
>> ClientRegionFactory operationRegionFactory =
>> clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>>
>> *operationRegionFactory.addCacheListener(new OperationCacheListener());*
>> operatonRegionFactory. ...
>>
>> Region operation = operationRegionFactory.create("Operation");
>>
>> -John
>>
>>
>> On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu < <al...@gmail.com>
>> ali.koyuncu@gmail.com> wrote:
>>
>>> Dear all,
>>>
>>> I created a region named Operation.
>>>
>>> What I want to do is to get notified upon creating or updating record in
>>> this region.
>>>
>>> Following are my code segments:
>>>
>>> *Listener (named OperationCacheListener):*
>>>
>>>   public void afterCreate(EntryEvent event) {
>>>
>>>    iEvent message = (iEvent) event.getNewValue();
>>>
>>>    if(message instanceof CmdStartCSS)
>>>    {
>>>     logger.debug("[OperationCacheListener][Command: Start][Key: {}]");
>>>
>>>     try {
>>>     CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>>>     DialManager.getInstance().Start(command);
>>>     }
>>>     catch(Exception e)
>>>     {
>>>     logger.error("[OperationCacheListener][Start][{}][Exception: {}]",
>>> e.getClass().getSimpleName(), e.getMessage());
>>>     }
>>>
>>>    }
>>>    else if(message instanceof CmdStopCSS)
>>>    {
>>>     logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
>>>     try {
>>> DialManager.getInstance().Stop();
>>> } catch (Exception e) {
>>> //
>>> }
>>>    }
>>>
>>>   }
>>>
>>>   public void afterUpdate(EntryEvent event)
>>>   {
>>>  System.err.println("Region entry was updated.");
>>>   }
>>>
>>>
>>> *How I initiate the listener:*
>>>
>>> this.listener = new OperationCacheListener();
>>> this.OperationRegion = cache
>>> .<String,
>>> iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>>> .initCacheListeners(new CacheListener[]
>>>    {this.listener})
>>> .create(OperationRegionName);
>>>
>>>
>>> *PROBLEM:*
>>>
>>> When I am to create/update a record in this region, my events are not
>>> triggered.
>>>
>>> Could you please check and tell me where I am wrong or missing? (If you
>>> have a sample code on this matter, I will be glad).
>>>
>>> Thank you in advance.
>>>
>>>
>>> --
>>>
>>> Saygılarımla, with my warm regards,
>>>
>>> Ali KOYUNCU
>>>
>>
>>
>>
>> --
>> -John
>> 503-504-8657
>> john.blum10101 (skype)
>>
>
>
>
> --
>
> Saygılarımla, with my warm regards,
>
> Ali KOYUNCU
>
>
>


-- 

Saygılarımla, with my warm regards,

Ali KOYUNCU

Re: Question about Region Events

Posted by Udo Kohlmeyer <uk...@pivotal.io>.
Hi there Ali,

When you say "it does not fetch any event" do you mean you are 
inserting/updating data entries on the server and the client does not 
get notified? Or are you making changes on the client and not being 
notified?

CacheListeners or CacheWriters should fire when you are making your 
local region (in your case client).

In order to have events propagated from the server to the client you 
need to use "registerInterest" on your client region. This can be turned on:

 1. enable subscriptions on your client pool, by setting
    "subscriptions-enabled=true"
 2. On the client region set
    "operationRegion.registerInterest("ALL_KEYS",
    InterestResultPolicy.KEYS_VALUES)

After this any changes on the server will be propagated to your client.

Is this the functionality you are looking for?

--Udo

On 24/05/2016 2:00 am, Ali Koyuncu wrote:
> John,
>
> My code as as follows:
>
> this.listener = new OperationCacheListener();
> this.OperationRegion = cache
> .<String, iEvent>createClientRegionFactory(ClientRegionShortcut.PROXY)
> .initCacheListeners(new CacheListener[]
>    {this.listener})
> .addCacheListener(this.listener)
> .create(OperationRegionName);
>
>
> where;
>
> private Region<String, iEvent> OperationRegion;
>
> privateClientCache cache;
>
> Despite I registered the listener, it doesn't fetch any event.
>
> Is the above code segment true?
>
> On Mon, May 23, 2016 at 6:49 PM, John Blum <jblum@pivotal.io 
> <ma...@pivotal.io>> wrote:
>
>     Hi Ali-
>
>     You need to register the CacheListener on the /Region/ in which
>     the data access operations/entry events (gets/puts/etc) are taking
>     place.  E.g. ...
>
>     ClientRegionFactory operationRegionFactory =
>     clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>
>     *operationRegionFactory.addCacheListener(new
>     OperationCacheListener());*
>     operatonRegionFactory. ...
>
>     Region operation = operationRegionFactory.create("Operation");
>
>     -John
>
>
>     On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu
>     <ali.koyuncu@gmail.com <ma...@gmail.com>> wrote:
>
>         Dear all,
>
>         I created a region named Operation.
>
>         What I want to do is to get notified upon creating or updating
>         record in this region.
>
>         Following are my code segments:
>
>         *Listener (named /OperationCacheListener/):*
>         *
>         *
>         **public void afterCreate(EntryEvent event) {
>            iEvent message = (iEvent) event.getNewValue();
>            if(message instanceof CmdStartCSS)
>            {
>         logger.debug("[OperationCacheListener][Command: Start][Key: {}]");
>         try {
>         CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>         DialManager.getInstance().Start(command);
>         }
>         catch(Exception e)
>         {
>         logger.error("[OperationCacheListener][Start][{}][Exception:
>         {}]", e.getClass().getSimpleName(), e.getMessage());
>         }
>            }
>            else if(message instanceof CmdStopCSS)
>            {
>         logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
>         try {
>         DialManager.getInstance().Stop();
>         } catch (Exception e) {
>         //
>         }
>            }
>           }
>           public void afterUpdate(EntryEvent event)
>           {
>          System.err.println("Region entry was updated.");
>           }
>         *
>         *
>         *
>         *
>         *How I initiate the listener:*
>         *
>         *
>         this.listener = new OperationCacheListener();
>         this.OperationRegion = cache
>         .<String,
>         iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>         .initCacheListeners(new CacheListener[]
>            {this.listener})
>         .create(OperationRegionName);
>
>
>         *PROBLEM:*
>         *
>         *
>         When I am to create/update a record in this region, my events
>         are not triggered.
>
>         Could you please check and tell me where I am wrong or
>         missing? (If you have a sample code on this matter, I will be
>         glad).
>
>         Thank you in advance.
>
>         -- 
>
>         Sayg\u0131lar\u0131mla, with my warm regards,
>
>         Ali KOYUNCU
>
>
>
>
>     -- 
>     -John
>     503-504-8657 <tel:503-504-8657>
>     john.blum10101 (skype)
>
>
>
>
> -- 
>
> Sayg\u0131lar\u0131mla, with my warm regards,
>
> Ali KOYUNCU


Re: Question about Region Events

Posted by Ali Koyuncu <al...@gmail.com>.
John,

My code as as follows:

this.listener = new OperationCacheListener();
this.OperationRegion = cache
.<String, iEvent>createClientRegionFactory(ClientRegionShortcut.PROXY)
.initCacheListeners(new CacheListener[]
   {this.listener})
.addCacheListener(this.listener)
.create(OperationRegionName);


where;

private Region<String, iEvent> OperationRegion;

private ClientCache cache;

Despite I registered the listener, it doesn't fetch any event.

Is the above code segment true?

On Mon, May 23, 2016 at 6:49 PM, John Blum <jb...@pivotal.io> wrote:

> Hi Ali-
>
> You need to register the CacheListener on the *Region* in which the data
> access operations/entry events (gets/puts/etc) are taking place.  E.g. ...
>
> ClientRegionFactory operationRegionFactory =
> clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
>
> *operationRegionFactory.addCacheListener(new OperationCacheListener());*
> operatonRegionFactory. ...
>
> Region operation = operationRegionFactory.create("Operation");
>
> -John
>
>
> On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu <al...@gmail.com>
> wrote:
>
>> Dear all,
>>
>> I created a region named Operation.
>>
>> What I want to do is to get notified upon creating or updating record in
>> this region.
>>
>> Following are my code segments:
>>
>> *Listener (named OperationCacheListener):*
>>
>>   public void afterCreate(EntryEvent event) {
>>
>>    iEvent message = (iEvent) event.getNewValue();
>>
>>    if(message instanceof CmdStartCSS)
>>    {
>>     logger.debug("[OperationCacheListener][Command: Start][Key: {}]");
>>
>>     try {
>>     CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>>     DialManager.getInstance().Start(command);
>>     }
>>     catch(Exception e)
>>     {
>>     logger.error("[OperationCacheListener][Start][{}][Exception: {}]",
>> e.getClass().getSimpleName(), e.getMessage());
>>     }
>>
>>    }
>>    else if(message instanceof CmdStopCSS)
>>    {
>>     logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
>>     try {
>> DialManager.getInstance().Stop();
>> } catch (Exception e) {
>> //
>> }
>>    }
>>
>>   }
>>
>>   public void afterUpdate(EntryEvent event)
>>   {
>>  System.err.println("Region entry was updated.");
>>   }
>>
>>
>> *How I initiate the listener:*
>>
>> this.listener = new OperationCacheListener();
>> this.OperationRegion = cache
>> .<String,
>> iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>> .initCacheListeners(new CacheListener[]
>>    {this.listener})
>> .create(OperationRegionName);
>>
>>
>> *PROBLEM:*
>>
>> When I am to create/update a record in this region, my events are not
>> triggered.
>>
>> Could you please check and tell me where I am wrong or missing? (If you
>> have a sample code on this matter, I will be glad).
>>
>> Thank you in advance.
>>
>>
>> --
>>
>> Saygılarımla, with my warm regards,
>>
>> Ali KOYUNCU
>>
>
>
>
> --
> -John
> 503-504-8657
> john.blum10101 (skype)
>



-- 

Saygılarımla, with my warm regards,

Ali KOYUNCU

Re: Question about Region Events

Posted by John Blum <jb...@pivotal.io>.
Hi Ali-

You need to register the CacheListener on the *Region* in which the data
access operations/entry events (gets/puts/etc) are taking place.  E.g. ...

ClientRegionFactory operationRegionFactory =
clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);

*operationRegionFactory.addCacheListener(new OperationCacheListener());*
operatonRegionFactory. ...

Region operation = operationRegionFactory.create("Operation");

-John


On Mon, May 23, 2016 at 1:24 AM, Ali Koyuncu <al...@gmail.com> wrote:

> Dear all,
>
> I created a region named Operation.
>
> What I want to do is to get notified upon creating or updating record in
> this region.
>
> Following are my code segments:
>
> *Listener (named OperationCacheListener):*
>
>   public void afterCreate(EntryEvent event) {
>
>    iEvent message = (iEvent) event.getNewValue();
>
>    if(message instanceof CmdStartCSS)
>    {
>     logger.debug("[OperationCacheListener][Command: Start][Key: {}]");
>
>     try {
>     CmdStartCSS command = (CmdStartCSS) event.getNewValue();
>     DialManager.getInstance().Start(command);
>     }
>     catch(Exception e)
>     {
>     logger.error("[OperationCacheListener][Start][{}][Exception: {}]",
> e.getClass().getSimpleName(), e.getMessage());
>     }
>
>    }
>    else if(message instanceof CmdStopCSS)
>    {
>     logger.debug("[OperationCacheListener][Command: Stop][Key: {}]");
>     try {
> DialManager.getInstance().Stop();
> } catch (Exception e) {
> //
> }
>    }
>
>   }
>
>   public void afterUpdate(EntryEvent event)
>   {
>  System.err.println("Region entry was updated.");
>   }
>
>
> *How I initiate the listener:*
>
> this.listener = new OperationCacheListener();
> this.OperationRegion = cache
> .<String,
> iEvent>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
> .initCacheListeners(new CacheListener[]
>    {this.listener})
> .create(OperationRegionName);
>
>
> *PROBLEM:*
>
> When I am to create/update a record in this region, my events are not
> triggered.
>
> Could you please check and tell me where I am wrong or missing? (If you
> have a sample code on this matter, I will be glad).
>
> Thank you in advance.
>
>
> --
>
> Saygılarımla, with my warm regards,
>
> Ali KOYUNCU
>



-- 
-John
503-504-8657
john.blum10101 (skype)