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 <[email protected]> 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 <[email protected]> > 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 <[email protected]> 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 < <[email protected]> >>> [email protected]> 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)
