All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.geode.cache.asyncqueue.AsyncEventListener Maven / Gradle / Ivy

Go to download

Apache Geode provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing

There is a newer version: 1.15.1
Show newest version
/*
 * 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.
 */

package org.apache.geode.cache.asyncqueue;

import java.util.List;

import org.apache.geode.cache.CacheCallback;

/**
 * A callback for events passing through the AsyncEventQueue to which this listener is
 * attached. Implementers of interface AsyncEventListener process batches of
 * AsyncEvent delivered by the corresponding AsyncEventQueue. 
* A sample implementation of this interface is as follows:
* *
 * public class MyEventListener implements AsyncEventListener {
 *
 *   public boolean processEvents(List events) {
 *     for (Iterator i = events.iterator(); i.hasNext();) {
 *       AsyncEvent event = (AsyncEvent) i.next();
 * 
 *       String originalRegionName = event.getRegion().getName();
 *       // For illustration purpose, use the event to update the duplicate of above region.
 *       final Region duplicateRegion =
 *           CacheHelper.getCache().getRegion(originalRegionName + "_DUP");
 * 
 *       final Object key = event.getKey();
 *       final Object value = event.getDeserializedValue();
 *       final Operation op = event.getOperation();
 * 
 *       if (op.isCreate()) {
 *         duplicateRegion.create(key, value);
 *       } else if (op.isUpdate()) {
 *         duplicateRegion.put(key, value);
 *       } else if (op.isDestroy()) {
 *         duplicateRegion.destroy(key);
 *       }
 * 
 *     }
 *     return true;
 *   }
 * }
 * 
* * @since GemFire 7.0 */ public interface AsyncEventListener extends CacheCallback { /** * Process the list of AsyncEvents. This method will asynchronously be called when * events are queued to be processed. The size of the list will be up to batch size events where * batch size is defined in the AsyncEventQueueFactory. * * @param events The list of AsyncEvent to process * * @return boolean True represents whether the events were successfully processed, false * otherwise. */ public boolean processEvents(List events); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy