GigaSpaces XAP 7.0 API

org.openspaces.events.asyncpolling
Class SimpleAsyncPollingEventListenerContainer

java.lang.Object
  extended by org.openspaces.events.AbstractSpaceListeningContainer
      extended by org.openspaces.events.AbstractEventListenerContainer
          extended by org.openspaces.events.AbstractTemplateEventListenerContainer
              extended by org.openspaces.events.AbstractTransactionalEventListenerContainer
                  extended by org.openspaces.events.asyncpolling.SimpleAsyncPollingEventListenerContainer
All Implemented Interfaces:
EventListener, ServiceDetailsProvider, ServiceMonitorsProvider, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, ApplicationListener, Lifecycle

public class SimpleAsyncPollingEventListenerContainer
extends AbstractTransactionalEventListenerContainer

Async polling event container uses the space async operation capabilities (such as GigaSpace.asyncTake(Object) in order to simulate events (optionally transactional).

Actual event listener is perfomed in an AsyncFutureListener, and once the result is processed, another async operation is perfomed. This allows to require no threads running and perfoming the blocking take operation as is the case with the SimplePollingEventListenerContainer.

The number of async operarions executed on startup can be controlled using setConcurrentConsumers(int). The rest of the operations will be driven by the results arriving, but in essence, there will be concurrent async operations performed based on the inital number of concurrent consumers.

The actual execution of an async operation is abstracted using AsyncOperationHandler with default implementation for take, read, and exclusive read lock.

Author:
kimchy

Field Summary
static long DEFAULT_RECEIVE_TIMEOUT
          The default receive timeout: 60000 ms = 60 seconds = 1 minute.
 
Fields inherited from class org.openspaces.events.AbstractEventListenerContainer
failedEvents, processedEvents
 
Fields inherited from class org.openspaces.events.AbstractSpaceListeningContainer
beanName, logger
 
Constructor Summary
SimpleAsyncPollingEventListenerContainer()
           
 
Method Summary
protected  void doAfterStart()
           
protected  void doInitialize()
          A callback to perform custom initialization steps.
protected  void doShutdown()
          Perform any custom shutdown operations.
protected  long getReceiveTimeout()
          Returns the timeout used for receive calls, in millisecond.
 ServiceDetails[] getServicesDetails()
          Retruns one or more service details that the service exposes.
 ServiceMonitors[] getServicesMonitors()
          Retruns one or more service details that the service exposes.
 void initialize()
          Initialize this container.
 void setAsyncOperationHandler(AsyncOperationHandler asyncOperationHandler)
          Sets the async operation handler abstracting the actual async operation perfomred.
 void setConcurrentConsumers(int concurrentConsumers)
          Sets the number of concurrent async operation performed by this container.
 void setReceiveTimeout(long receiveTimeout)
          Set the timeout to use for receive calls, in milliseconds.
 
Methods inherited from class org.openspaces.events.AbstractTransactionalEventListenerContainer
getTransactionDefinition, getTransactionManager, getTransactionManagerName, isTransactional, setDisableTransactionValidation, setTransactionIsolationLevel, setTransactionIsolationLevelName, setTransactionManager, setTransactionName, setTransactionTimeout, validateConfiguration
 
Methods inherited from class org.openspaces.events.AbstractTemplateEventListenerContainer
afterPropertiesSet, getReceiveTemplate, getTemplate, isPerformSnapshot, setPerformSnapshot, setTemplate
 
Methods inherited from class org.openspaces.events.AbstractEventListenerContainer
doStart, executeListener, getActualEventListener, getApplicationContext, getEventListener, getEventListenerClass, getFailedEvents, getProcessedEvents, handleListenerException, invokeExceptionListener, invokeListener, setApplicationContext, setEventListener, setEventListenerRef
 
Methods inherited from class org.openspaces.events.AbstractSpaceListeningContainer
destroy, doBeforeStop, doRescheduleTask, doStop, getBeanName, getGigaSpace, getStatus, isActive, isRunning, message, onApplicationEvent, rescheduleTaskIfNecessary, setActiveWhenPrimary, setAutoStart, setBeanName, setGigaSpace, setRegisterSpaceModeListener, shutdown, start, stop, waitWhileNotRunning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RECEIVE_TIMEOUT

public static final long DEFAULT_RECEIVE_TIMEOUT
The default receive timeout: 60000 ms = 60 seconds = 1 minute.

See Also:
Constant Field Values
Constructor Detail

SimpleAsyncPollingEventListenerContainer

public SimpleAsyncPollingEventListenerContainer()
Method Detail

setReceiveTimeout

public void setReceiveTimeout(long receiveTimeout)
Set the timeout to use for receive calls, in milliseconds. The default is 60000 ms, that is, 1 minute.

NOTE: This value needs to be smaller than the transaction timeout used by the transaction manager (in the appropriate unit, of course).

See Also:
GigaSpace.take(Object,long)

getReceiveTimeout

protected long getReceiveTimeout()
Returns the timeout used for receive calls, in millisecond. The default is 60000 ms, that is, 1 minute.


setAsyncOperationHandler

public void setAsyncOperationHandler(AsyncOperationHandler asyncOperationHandler)
Sets the async operation handler abstracting the actual async operation perfomred.


setConcurrentConsumers

public void setConcurrentConsumers(int concurrentConsumers)
Sets the number of concurrent async operation performed by this container.


getServicesDetails

public ServiceDetails[] getServicesDetails()
Description copied from interface: ServiceDetailsProvider
Retruns one or more service details that the service exposes.


getServicesMonitors

public ServiceMonitors[] getServicesMonitors()
Description copied from interface: ServiceMonitorsProvider
Retruns one or more service details that the service exposes.


initialize

public void initialize()
                throws DataAccessException
Description copied from class: AbstractSpaceListeningContainer
Initialize this container. If this container is not configured with "activeWhenPrimary" flag set to true will call AbstractSpaceListeningContainer.doStart() (if it is set to true, lifecycle of the container will be controlled by the current space mode). AbstractSpaceListeningContainer.doInitialize() will be called for additional initialization after the possible AbstractSpaceListeningContainer.doStart() call.

Overrides:
initialize in class AbstractTransactionalEventListenerContainer
Throws:
DataAccessException
See Also:
AbstractSpaceListeningContainer.onApplicationEvent(org.springframework.context.ApplicationEvent)

doInitialize

protected void doInitialize()
                     throws DataAccessException
Description copied from class: AbstractSpaceListeningContainer
A callback to perform custom initialization steps.

Specified by:
doInitialize in class AbstractSpaceListeningContainer
Throws:
DataAccessException

doShutdown

protected void doShutdown()
                   throws DataAccessException
Description copied from class: AbstractSpaceListeningContainer
Perform any custom shutdown operations.

Specified by:
doShutdown in class AbstractSpaceListeningContainer
Throws:
DataAccessException
See Also:
AbstractSpaceListeningContainer.shutdown()

doAfterStart

protected void doAfterStart()
                     throws DataAccessException
Overrides:
doAfterStart in class AbstractSpaceListeningContainer
Throws:
DataAccessException

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.