GigaSpaces XAP 9.7.2 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:
com.gigaspaces.internal.dump.InternalDumpProcessor, EventListener, ServiceDetailsProvider, ServiceMonitorsProvider, Aware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, ApplicationListener<ApplicationEvent>, Lifecycle

public class SimpleAsyncPollingEventListenerContainer
extends AbstractTransactionalEventListenerContainer
implements com.gigaspaces.internal.dump.InternalDumpProcessor

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.AbstractTransactionalEventListenerContainer
disableTransactionValidation
 
Fields inherited from class org.openspaces.events.AbstractEventListenerContainer
exceptionHandler, 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.
 String getName()
           
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 process(com.gigaspaces.internal.dump.InternalDump dump)
           
 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
getReceiveTemplate, getTemplate, isDynamicTemplate, isPerformSnapshot, setDynamicTemplate, setPerformSnapshot, setTemplate
 
Methods inherited from class org.openspaces.events.AbstractEventListenerContainer
doStart, executeListener, getActualEventListener, getApplicationContext, getEventListener, getEventListenerClass, getExceptionHandler, getFailedEvents, getProcessedEvents, handleListenerException, invokeExceptionListener, invokeListener, setApplicationContext, setEventListener, setEventListenerRef, setExceptionHandler
 
Methods inherited from class org.openspaces.events.AbstractSpaceListeningContainer
afterPropertiesSet, 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.

Specified by:
getServicesDetails in interface ServiceDetailsProvider

getServicesMonitors

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

Specified by:
getServicesMonitors in interface ServiceMonitorsProvider

getName

public String getName()
Specified by:
getName in interface com.gigaspaces.internal.dump.InternalDumpProcessor

process

public void process(com.gigaspaces.internal.dump.InternalDump dump)
             throws com.gigaspaces.internal.dump.InternalDumpProcessorFailedException
Specified by:
process in interface com.gigaspaces.internal.dump.InternalDumpProcessor
Throws:
com.gigaspaces.internal.dump.InternalDumpProcessorFailedException

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 9.7.2 API

Copyright © GigaSpaces.