public class ContinuousQueryListenerContainer extends Object implements BeanFactoryAware, BeanNameAware, InitializingBean, DisposableBean, SmartLifecycle
Executor,
RegionService,
Pool,
PoolManager,
CqAttributes,
CqEvent,
CqListener,
CqQuery,
QueryService,
BeanFactory,
BeanFactoryAware,
BeanNameAware,
DisposableBean,
InitializingBean,
SmartLifecycle,
SimpleAsyncTaskExecutor,
TaskExecutor,
PoolResolver,
DefaultableDelegatingPoolAdapter,
DelegatingPoolAdapter,
ErrorHandler| Modifier and Type | Class and Description |
|---|---|
protected class |
ContinuousQueryListenerContainer.EventDispatcherAdapter |
| Modifier and Type | Field and Description |
|---|---|
protected static PoolResolver |
DEFAULT_POOL_RESOLVER |
static String |
DEFAULT_THREAD_NAME_PREFIX |
protected org.slf4j.Logger |
logger |
DEFAULT_PHASE| Constructor and Description |
|---|
ContinuousQueryListenerContainer() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addContinuousQueryDefinition(ContinuousQueryDefinition definition) |
void |
addListener(ContinuousQueryDefinition definition)
Adds a
Continuous Query (CQ) definition to the (potentially running) container. |
void |
afterPropertiesSet() |
protected void |
applyContinuousQueryListenerContainerConfigurers(ContinuousQueryListenerContainerConfigurer... configurers)
Applies an array of
ContinuousQueryListenerContainerConfigurer objects to customize the configuration
of this ContinuousQueryListenerContainer. |
protected void |
applyContinuousQueryListenerContainerConfigurers(Iterable<ContinuousQueryListenerContainerConfigurer> configurers)
Applies an
Iterable of ContinuousQueryListenerContainerConfigurer objects to customize
the configuration of this ContinuousQueryListenerContainer. |
protected Executor |
createDefaultTaskExecutor()
Creates a default
TaskExecutor. |
void |
destroy() |
protected void |
dispatchEvent(ContinuousQueryListener listener,
org.apache.geode.cache.query.CqEvent event)
Asynchronously dispatches the
CQ event to the targeted ContinuousQueryListener. |
protected BeanFactory |
getBeanFactory()
Returns a reference to the configured
BeanFactory. |
protected String |
getBeanName()
Returns the configured
bean name of this container. |
protected ContinuousQueryListenerContainerConfigurer |
getCompositeContinuousQueryListenerContainerConfigurer()
Returns a Composite object containing
the collection of
ContinuousQueryListenerContainerConfigurer objects used to customize the configuration
of this ContinuousQueryListenerContainer. |
protected Queue<org.apache.geode.cache.query.CqQuery> |
getContinuousQueries()
Returns a reference to all the configured/registered
Continuous Queries. |
protected Set<ContinuousQueryDefinition> |
getContinuousQueryDefinitions()
Returns a reference to all the configured
ContinuousQueryDefinitions. |
Optional<ErrorHandler> |
getErrorHandler()
Returns an
Optional reference to the configured ErrorHandler invoked when
any unhandled Exceptions are thrown when invoking CQ listeners processing CQ events. |
int |
getPhase()
Gets the phase in which this CQ listener container will start in the Spring container.
|
String |
getPoolName()
Returns the configured
pool name. |
PoolResolver |
getPoolResolver()
|
org.apache.geode.cache.query.QueryService |
getQueryService()
Returns a reference to the configured
QueryService. |
Executor |
getTaskExecutor()
Returns a reference to the configured
TaskExecutor. |
boolean |
isActive()
Determines whether this container is currently active, i.e., whether it has been setup and initialized
but not shutdown yet.
|
boolean |
isAutoStartup()
Determines whether this CQ listener container will automatically start on startup.
|
boolean |
isRunning()
Determines whether the container has be started and is currently running.
|
protected org.apache.geode.cache.query.CqListener |
newCqListener(ContinuousQueryListener listener) |
void |
setAutoStartup(boolean autoStartup)
Sets whether the CQ listener container should automatically start on startup.
|
void |
setBeanFactory(BeanFactory beanFactory)
Sets the
BeanFactory containing this bean. |
void |
setBeanName(String name)
Set the name of the bean in the bean factory that created this bean.
|
void |
setCache(org.apache.geode.cache.RegionService cache)
Set the underlying RegionService (GemFire Cache) used for registering Queries.
|
void |
setContinuousQueryListenerContainerConfigurers(ContinuousQueryListenerContainerConfigurer... configurers)
Null-safe operation setting an array of
ContinuousQueryListenerContainerConfigurer objects used to
customize the configuration of this ContinuousQueryListenerContainer. |
void |
setContinuousQueryListenerContainerConfigurers(List<ContinuousQueryListenerContainerConfigurer> configurers)
Null-safe operation setting an
Iterable of ContinuousQueryListenerContainerConfigurer objects
used to customize the configuration of this ContinuousQueryListenerContainer. |
void |
setErrorHandler(ErrorHandler errorHandler)
Set an
ErrorHandler to be invoked in case of any uncaught Exceptions thrown
while processing a CQ event. |
void |
setPhase(int phase)
Sets the phase in which this CQ listener container will start in the Spring container.
|
void |
setPoolName(String poolName)
Set the name of the
Pool used for performing the queries by this container. |
void |
setPoolResolver(PoolResolver poolResolver)
|
void |
setQueryListeners(Set<ContinuousQueryDefinition> queries)
Attaches the given query definitions.
|
void |
setQueryService(org.apache.geode.cache.query.QueryService queryService)
Set the GemFire QueryService used by this container to create ContinuousQueries (CQ).
|
void |
setTaskExecutor(Executor taskExecutor)
Sets the Task Executor used for running the event listeners when messages are received.
|
void |
start() |
void |
stop() |
void |
stop(Runnable callback) |
public static final String DEFAULT_THREAD_NAME_PREFIX
protected static final PoolResolver DEFAULT_POOL_RESOLVER
protected final org.slf4j.Logger logger
public void afterPropertiesSet()
afterPropertiesSet in interface InitializingBeanprotected void applyContinuousQueryListenerContainerConfigurers(ContinuousQueryListenerContainerConfigurer... configurers)
ContinuousQueryListenerContainerConfigurer objects to customize the configuration
of this ContinuousQueryListenerContainer.configurers - array of ContinuousQueryListenerContainerConfigurer used to customize
the configuration of this ContinuousQueryListenerContainer.ContinuousQueryListenerContainerConfigurerprotected void applyContinuousQueryListenerContainerConfigurers(Iterable<ContinuousQueryListenerContainerConfigurer> configurers)
Iterable of ContinuousQueryListenerContainerConfigurer objects to customize
the configuration of this ContinuousQueryListenerContainer.configurers - Iterable of ContinuousQueryListenerContainerConfigurer used to customize
the configuration of this ContinuousQueryListenerContainer.ContinuousQueryListenerContainerConfigurerprotected Executor createDefaultTaskExecutor()
TaskExecutor.
Called if no explicit TaskExecutor has been configured.
The default implementation builds a SimpleAsyncTaskExecutor with the specified bean name
(or the class name, if no bean name is specified) as the Thread name prefix.
TaskExecutor used to process CQ events asynchronously.SimpleAsyncTaskExecutorpublic boolean isActive()
public void setAutoStartup(boolean autoStartup)
autoStartup - a boolean value indicating whether this CQ listener container should automatically start.public boolean isAutoStartup()
isAutoStartup in interface SmartLifecycleSmartLifecycle.isAutoStartup()public boolean isRunning()
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
BeanFactory containing this bean.setBeanFactory in interface BeanFactoryAwarebeanFactory - the Spring BeanFactory containing this bean.BeansException - if an initialization error occurs.protected BeanFactory getBeanFactory()
BeanFactory.BeanFactory.BeanFactorypublic void setBeanName(String name)
Invoked after population of normal bean properties but before an
init callback such as InitializingBean.afterPropertiesSet()
or a custom init-method.
setBeanName in interface BeanNameAwarename - the name of the bean in the factory.protected String getBeanName()
bean name of this container.bean name of this container.public void setCache(org.apache.geode.cache.RegionService cache)
cache - the RegionService (GemFire Cache) used for registering Queries.RegionServiceprotected Queue<org.apache.geode.cache.query.CqQuery> getContinuousQueries()
Continuous Queries.Continuous Queries.CqQuery,
Queueprotected Set<ContinuousQueryDefinition> getContinuousQueryDefinitions()
ContinuousQueryDefinitions.ContinuousQueryDefinitions.ContinuousQueryDefinition,
Setpublic void setContinuousQueryListenerContainerConfigurers(ContinuousQueryListenerContainerConfigurer... configurers)
ContinuousQueryListenerContainerConfigurer objects used to
customize the configuration of this ContinuousQueryListenerContainer.configurers - array of ContinuousQueryListenerContainerConfigurer objects used to customize
the configuration of this ContinuousQueryListenerContainer.ContinuousQueryListenerContainerConfigurer,
setContinuousQueryListenerContainerConfigurers(List)public void setContinuousQueryListenerContainerConfigurers(List<ContinuousQueryListenerContainerConfigurer> configurers)
Iterable of ContinuousQueryListenerContainerConfigurer objects
used to customize the configuration of this ContinuousQueryListenerContainer.configurers - Iterable of ContinuousQueryListenerContainerConfigurer objects used to
customize the configuration of this ContinuousQueryListenerContainer.ContinuousQueryListenerContainerConfigurerprotected ContinuousQueryListenerContainerConfigurer getCompositeContinuousQueryListenerContainerConfigurer()
ContinuousQueryListenerContainerConfigurer objects used to customize the configuration
of this ContinuousQueryListenerContainer.ContinuousQueryListenerContainerConfigurer objects
used to customize the configuration of this ContinuousQueryListenerContainer.ContinuousQueryListenerContainerConfigurerpublic void setErrorHandler(ErrorHandler errorHandler)
ErrorHandler to be invoked in case of any uncaught Exceptions thrown
while processing a CQ event.
By default there is no ErrorHandler configured so error-level logging is the only result.errorHandler - ErrorHandler invoked when uncaught Exceptions are thrown
while processing the CQ event.ErrorHandlerpublic Optional<ErrorHandler> getErrorHandler()
Optional reference to the configured ErrorHandler invoked when
any unhandled Exceptions are thrown when invoking CQ listeners processing CQ events.Optional reference to the configured ErrorHandler.ErrorHandlerpublic void setPhase(int phase)
phase - the phase value of this CQ listener container.public int getPhase()
getPhase in interface PhasedgetPhase in interface SmartLifecyclePhased.getPhase()public void setPoolName(String poolName)
Pool used for performing the queries by this container.poolName - the name of the pool to be used by the containerpublic String getPoolName()
pool name.pool name.public void setPoolResolver(PoolResolver poolResolver)
poolResolver - the configured PoolResolver used to resolve Pool objects
by name.PoolResolverpublic PoolResolver getPoolResolver()
PoolResolver.PoolResolverpublic void setQueryListeners(Set<ContinuousQueryDefinition> queries)
queries - set of queriespublic void setQueryService(org.apache.geode.cache.query.QueryService queryService)
queryService - the GemFire QueryService object used by the container to create ContinuousQueries (CQ).QueryServicepublic org.apache.geode.cache.query.QueryService getQueryService()
QueryService.QueryService.QueryServicepublic void setTaskExecutor(Executor taskExecutor)
SimpleAsyncTaskExecutor will be used by default.
The task executor can be adjusted depending on the work done by the listeners and the number of
messages coming in.taskExecutor - The Task Executor used to run event listeners when query results messages are received.Executorpublic Executor getTaskExecutor()
TaskExecutor.TaskExecutor.Executorpublic void addListener(ContinuousQueryDefinition definition)
Continuous Query (CQ) definition to the (potentially running) container.
If the container is running, the listener starts receiving (matching) messages as soon as possible.definition - Continuous Query (CQ) definition to register.ContinuousQueryDefinitionpublic boolean addContinuousQueryDefinition(ContinuousQueryDefinition definition)
protected org.apache.geode.cache.query.CqListener newCqListener(ContinuousQueryListener listener)
protected void dispatchEvent(ContinuousQueryListener listener, org.apache.geode.cache.query.CqEvent event)
CQ event to the targeted ContinuousQueryListener.listener - ContinuousQueryListener which will process/handle the CQ event.event - CQ event to process.ContinuousQueryListener,
CqEventpublic void stop(Runnable callback)
stop in interface SmartLifecyclepublic void destroy()
destroy in interface DisposableBeanCopyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.