GigaSpaces XAP 10.0.1 API

org.openspaces.events.notify
Class AbstractNotifyEventListenerContainer

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.notify.AbstractNotifyEventListenerContainer
All Implemented Interfaces:
EventListener, ServiceDetailsProvider, ServiceMonitorsProvider, Aware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, ApplicationListener<ApplicationEvent>, Lifecycle
Direct Known Subclasses:
SimpleNotifyEventListenerContainer

public abstract class AbstractNotifyEventListenerContainer
extends AbstractTransactionalEventListenerContainer

Base class for notifications based containers allowing to register listener that will be triggered by the space if notifications occur. Provides all the necessary parameters that are used by EventSessionConfig.

The container allows to set the template object used for the notify registration. Note, this can be a Pojo based template, or one of GigaSpace's query classes such as SQLQuery.

Masking of which operations will cause notifications can be set using setNotifyWrite(Boolean), setNotifyUpdate(Boolean), setNotifyTake(Boolean) and setNotifyLeaseExpire(Boolean). Note, if no flag is set, notifications will be send for write operations.

Batching of notifications can be turned on by setting both setBatchSize(Integer) and setBatchTime(Integer). When turning on batch notifications, the listener can choose whether to receive the events as an array (by setting setPassArrayAsIs(boolean) to true, or to receive the notifications one by one (setting it to false). By default, the setPassArrayAsIs(boolean) is set to false.

Fifo ordering of raised notification can be controlled by setting setFifo(boolean) flag to true. Note, for a full fifo based ordering the relevant entries in the space should be configured to be fifo as well.

Listener registration across replicated spaces can be set using setReplicateNotifyTemplate(boolean) and setTriggerNotifyTemplate(boolean).

The communication protocol between the space "server" and the even listener client can be configured using either setComType(int) or setComTypeName(String). The available options are COM_TYPE_UNICAST or COM_TYPE_MULTIPLEX. If using setComType(int) the integer constant value should be used. If using setComTypeName(String) the actual name of the com type can be used (unicast, multiplex or multicast). The default communication type is COM_TYPE_UNICAST.

The AbstractTemplateEventListenerContainer.setTemplate(Object) parameter is required in order to perform matching on which events to receive. If the AbstractEventListenerContainer.setEventListener(org.openspaces.events.SpaceDataEventListener) implements EventTemplateProvider and the template is directly set, the event listener will be used to get the template. This feature helps when event listeners directly can only work with a certain template and removes the requirement of configuring the template as well.

Provides invokeListenerWithTransaction(Object,Object,boolean,boolean) allowing to execute the listener within a transactional context. Also allows for the performTakeOnNotify to control if a take operation will be performed against the space with the given event data in order to remove it from the space.

Author:
kimchy
See Also:
EventSessionConfig, DataEventSession

Field Summary
static int COM_TYPE_MULTICAST
          Deprecated. Since 9.0.0
static int COM_TYPE_MULTIPLEX
          Deprecated. Since 9.7
static String COM_TYPE_PREFIX
          Deprecated. Since 9.7
static int COM_TYPE_UNICAST
          Deprecated. Since 9.7
 
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
AbstractNotifyEventListenerContainer()
           
 
Method Summary
protected  EventSessionConfig createEventSessionConfig()
          Creates a new EventSessionConfig based on the different parameters this container accepts.
protected  Integer getBatchPendingThreshold()
           
protected  Integer getBatchSize()
           
protected  Integer getBatchTime()
           
protected  int getCommType()
          Deprecated. Since 9.7
protected  Boolean getNotifyLeaseExpire()
           
protected  Boolean getNotifyMatchedUpdate()
           
protected  Boolean getNotifyRematchedUpdate()
           
protected  Boolean getNotifyTake()
           
protected  Boolean getNotifyUnmatched()
           
protected  Boolean getNotifyUpdate()
           
protected  Boolean getNotifyWrite()
           
protected  long getRenewDuration()
          Deprecated. Since 9.7
protected  long getRenewExpiration()
          Deprecated. Since 9.7
protected  long getRenewRTT()
          Deprecated. Since 9.7
 void initialize()
          Initialize this container.
protected  void invokeListenerWithTransaction(BatchRemoteEvent batchRemoteEvent, boolean performTakeOnNotify, boolean ignoreEventOnNullTake)
           
protected  void invokeListenerWithTransaction(Object eventData, Object source, boolean performTakeOnNotify, boolean ignoreEventOnNullTake)
          Executes the given listener.
protected  boolean isAutoRenew()
           
protected  boolean isBatchEnabled()
          Returns true when batching is enabled.
protected  Boolean isDurable()
           
protected  boolean isFifo()
           
protected  Boolean isGuaranteed()
           
protected  Boolean isNotifyAll()
           
protected  Boolean isNotifyLeaseExpire()
           
protected  Boolean isNotifyMatchedUpdate()
           
protected  Boolean isNotifyRematchedUpdate()
           
protected  Boolean isNotifyTake()
           
protected  Boolean isNotifyUnmatched()
           
protected  Boolean isNotifyUpdate()
          Turns on notifications for update operations.
protected  Boolean isNotifyWrite()
           
protected  boolean isPassArrayAsIs()
           
protected  Boolean isReplicateNotifyTemplate()
           
protected  Boolean isTriggerNotifyTemplate()
           
protected  EventRegistration registerListener(DataEventSession dataEventSession, RemoteEventListener listener)
          Registers a listener using the provided DataEventSession and based on different parameters set on this container.
 void setAutoRenew(boolean autoRenew)
          If setListenerLease(long) is set, automatically performs lease renewal.
 void setBatchPendingThreshold(Integer batchPendingThreshold)
          If set, turns batching event notifications where the server space accumalates notifications to be sent and then send them in batch.
 void setBatchSize(Integer batchSize)
          If set, turns batching event notifications where the server space accumalates notifications to be sent and then send them in batch.
 void setBatchTime(Integer batchTime)
          If set, turns batching event notifications where the server space accumalates notifications to be sent and then send them in batch.
 void setComType(int comType)
          Deprecated. This configuration is redundant and has no affect.
 void setComTypeName(String comTypeName)
          Deprecated. Since 9.7
 void setDurable(Boolean durable)
          Controls if notifications will sustain disconnections and failover.
 void setDynamicTemplate(Object templateProvider)
          Called before each take and read polling operation to change the template Overrides any template defined with AbstractTemplateEventListenerContainer.setTemplate(Object)
 void setFifo(boolean fifo)
          Determines if events arrives in the same order they were triggered by the space "server".
 void setGuaranteed(Boolean guaranteed)
          Deprecated. Since 9.0 use setDurable(Boolean) instead.
 void setLeaseListener(LeaseListener leaseListener)
          If setAutoRenew(boolean) is set to true sets the lease listener for it.
 void setListenerLease(long listenerLease)
          Deprecated. Since 9.7 - event listener with custom lease is deprecated.
 void setNotifyAll(Boolean notifyAll)
          Turns on notifications for all operations.
 void setNotifyFilter(INotifyDelegatorFilter notifyFilter)
          Allows to register a filter on the server side that can filter out or modify notifications that will be sent by the space "server".
 void setNotifyLeaseExpire(Boolean notifyLeaseExpire)
          Turns on notification for least expiration.
 void setNotifyMatchedUpdate(Boolean notifyMatchedUpdate)
          Turns on notifications for matched templates (a template that matches an entry after the entry was updated and not before).
 void setNotifyRematchedUpdate(Boolean notifyRematchedUpdate)
          Turns on notifications for re-matched templates (a template that matches an entry before and after the entry was updated).
 void setNotifyTake(Boolean notifyTake)
          Turns on notifications for take operations.
 void setNotifyUnmatched(Boolean notifyUnmatched)
          Turns on notifications for unmatched templates (a template that matched an entry but not it does not).
 void setNotifyUpdate(Boolean notifyUpdate)
          Turns on notifications for update operations.
 void setNotifyWrite(Boolean notifyWrite)
          Turns on notifications for write operations.
 void setPassArrayAsIs(boolean passArrayAsIs)
          When batching is turned on, should the batch of events be passed as an Object[] to the listener.
 void setRenewDuration(long renewDuration)
          Deprecated. Since 9.7
 void setRenewExpiration(long renewExpiration)
          Deprecated. Since 9.7
 void setRenewRTT(long renewRTT)
          Deprecated. Since 9.7
 void setReplicateNotifyTemplate(boolean replicateNotifyTemplate)
          If using a replicated space controls if the listener will be replicated between all the replicated cluster members.
 void setTriggerNotifyTemplate(boolean triggerNotifyTemplate)
          If using a replicated space controls if the listener that are replicated to cluster members will raise notifications.
protected  void validateConfiguration()
          Validate the configuration of this container.
 
Methods inherited from class org.openspaces.events.AbstractTransactionalEventListenerContainer
getTransactionDefinition, getTransactionManager, getTransactionManagerName, isTransactional, setDisableTransactionValidation, setTransactionIsolationLevel, setTransactionIsolationLevelName, setTransactionManager, setTransactionName, setTransactionTimeout
 
Methods inherited from class org.openspaces.events.AbstractTemplateEventListenerContainer
getReceiveTemplate, getTemplate, isDynamicTemplate, isPerformSnapshot, 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, doAfterStart, doBeforeStop, doInitialize, doRescheduleTask, doShutdown, 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
 
Methods inherited from interface org.openspaces.pu.service.ServiceDetailsProvider
getServicesDetails
 
Methods inherited from interface org.openspaces.pu.service.ServiceMonitorsProvider
getServicesMonitors
 

Field Detail

COM_TYPE_PREFIX

@Deprecated
public static final String COM_TYPE_PREFIX
Deprecated. Since 9.7
Custom Communication type is deprecated since 9.7 - the default is multiplex and there are no benefits for using unicast.

See Also:
Constant Field Values

COM_TYPE_UNICAST

@Deprecated
public static final int COM_TYPE_UNICAST
Deprecated. Since 9.7
Custom Communication type is deprecated since 9.7 - the default is multiplex and there are no benefits for using unicast.

See Also:
Constant Field Values

COM_TYPE_MULTIPLEX

public static final int COM_TYPE_MULTIPLEX
Deprecated. Since 9.7
Custom Communication type is deprecated since 9.7 - the default is multiplex and there are no benefits for using unicast.

See Also:
Constant Field Values

COM_TYPE_MULTICAST

@Deprecated
public static final int COM_TYPE_MULTICAST
Deprecated. Since 9.0.0
Multicast notifications are no longer supported. This enum value will be removed in future versions.

See Also:
Constant Field Values
Constructor Detail

AbstractNotifyEventListenerContainer

public AbstractNotifyEventListenerContainer()
Method Detail

setComType

@Deprecated
public void setComType(int comType)
Deprecated. This configuration is redundant and has no affect.


getCommType

@Deprecated
protected int getCommType()
Deprecated. Since 9.7

Custom Communication type is deprecated since 9.7 - the default is multiplex and there are no benefits for using unicast.


setComTypeName

@Deprecated
public void setComTypeName(String comTypeName)
Deprecated. Since 9.7

Custom Communication type is deprecated since 9.7 - the default is multiplex and there are no benefits for using unicast.


setFifo

public void setFifo(boolean fifo)
Determines if events arrives in the same order they were triggered by the space "server". Note, for a full fifo based ordering the relevant entries in the space should be configured to be fifo as well.


isFifo

protected boolean isFifo()

setBatchSize

public void setBatchSize(Integer batchSize)
If set, turns batching event notifications where the server space accumalates notifications to be sent and then send them in batch. The batch size controls the number of notifications are sent in each batch. If setBatchPendingThreshold(Integer) is not specified, this property will determine it as well. Note, if setting this property the setBatchTime(Integer) must be set as well.


getBatchSize

protected Integer getBatchSize()

setBatchTime

public void setBatchTime(Integer batchTime)
If set, turns batching event notifications where the server space accumalates notifications to be sent and then send them in batch. The batch time controls the elapsed time until the batch buffer is cleared and sent. The time is in milliseconds. Note, if setting this property the setBatchSize(Integer) must be set as well.


getBatchTime

protected Integer getBatchTime()

setBatchPendingThreshold

public void setBatchPendingThreshold(Integer batchPendingThreshold)
If set, turns batching event notifications where the server space accumalates notifications to be sent and then send them in batch. The batch pending threshold controls the number of notifications that will be accumulated before they are sent. Note, if this property not set, setBatchSize(Integer) will be used.


getBatchPendingThreshold

protected Integer getBatchPendingThreshold()

setAutoRenew

public void setAutoRenew(boolean autoRenew)
If setListenerLease(long) is set, automatically performs lease renewal. Defaults to false.

See Also:
setListenerLease(long)

isAutoRenew

protected boolean isAutoRenew()

getRenewExpiration

@Deprecated
protected long getRenewExpiration()
Deprecated. Since 9.7

The period of time your notifications stop being renewed. Only applies when setAutoRenew(boolean) is true.

Defaults to EventSessionConfig.DEFAULT_RENEW_EXPIRATION.


setRenewExpiration

@Deprecated
public void setRenewExpiration(long renewExpiration)
Deprecated. Since 9.7

The period of time your notifications stop being renewed. Only applies when setAutoRenew(boolean) is true.

Defaults to EventSessionConfig.DEFAULT_RENEW_EXPIRATION.


getRenewDuration

@Deprecated
protected long getRenewDuration()
Deprecated. Since 9.7

The period of time that passes between client failure, and the time your notifications stop being sent. use more than renewRTT. Only applies when setAutoRenew(boolean) is true.

Defaults to EventSessionConfig.DEFAULT_RENEW_DURATION.


setRenewDuration

@Deprecated
public void setRenewDuration(long renewDuration)
Deprecated. Since 9.7

The period of time that passes between client failure, and the time your notifications stop being sent. use more than renewRTT. Only applies when setAutoRenew(boolean) is true.

Defaults to EventSessionConfig.DEFAULT_RENEW_DURATION.


getRenewRTT

@Deprecated
protected long getRenewRTT()
Deprecated. Since 9.7

RoundTripTime - the time that takes to reach the server and return. Only applies when setAutoRenew(boolean) is true.

Defaults to EventSessionConfig.DEFAULT_RENEW_RTT.


setRenewRTT

@Deprecated
public void setRenewRTT(long renewRTT)
Deprecated. Since 9.7

RoundTripTime - the time that takes to reach the server and return. Only applies when setAutoRenew(boolean) is true.

Defaults to EventSessionConfig.DEFAULT_RENEW_RTT.


setLeaseListener

public void setLeaseListener(LeaseListener leaseListener)
If setAutoRenew(boolean) is set to true sets the lease listener for it.


setListenerLease

@Deprecated
public void setListenerLease(long listenerLease)
Deprecated. Since 9.7 - event listener with custom lease is deprecated.

Controls the lease associated with the registered listener. Defaults to Lease.FOREVER.

See Also:
setAutoRenew(boolean)

setNotifyFilter

public void setNotifyFilter(INotifyDelegatorFilter notifyFilter)
Allows to register a filter on the server side that can filter out or modify notifications that will be sent by the space "server". Note, this filter will be passed to the space server and used there.


setNotifyWrite

public void setNotifyWrite(Boolean notifyWrite)
Turns on notifications for write operations. Defaults to false.


isNotifyWrite

protected Boolean isNotifyWrite()

setNotifyUpdate

public void setNotifyUpdate(Boolean notifyUpdate)
Turns on notifications for update operations. Defaults to false.


isNotifyUpdate

protected Boolean isNotifyUpdate()
Turns on notifications for update operations. Defaults to false.


setNotifyTake

public void setNotifyTake(Boolean notifyTake)
Turns on notifications for take operations. Defaults to false.


isNotifyTake

protected Boolean isNotifyTake()

setNotifyAll

public void setNotifyAll(Boolean notifyAll)
Turns on notifications for all operations. This flag will override all the other notify flags (if set). Defaults to false.


isNotifyAll

protected Boolean isNotifyAll()

setNotifyLeaseExpire

public void setNotifyLeaseExpire(Boolean notifyLeaseExpire)
Turns on notification for least expiration. Defaults to false.


isNotifyLeaseExpire

protected Boolean isNotifyLeaseExpire()

setNotifyUnmatched

public void setNotifyUnmatched(Boolean notifyUnmatched)
Turns on notifications for unmatched templates (a template that matched an entry but not it does not). Defaults to false.


setNotifyMatchedUpdate

public void setNotifyMatchedUpdate(Boolean notifyMatchedUpdate)
Turns on notifications for matched templates (a template that matches an entry after the entry was updated and not before). Defaults to false.

Since:
9.1

setNotifyRematchedUpdate

public void setNotifyRematchedUpdate(Boolean notifyRematchedUpdate)
Turns on notifications for re-matched templates (a template that matches an entry before and after the entry was updated). Defaults to false.

Since:
9.1

isNotifyUnmatched

protected Boolean isNotifyUnmatched()

isNotifyMatchedUpdate

protected Boolean isNotifyMatchedUpdate()

isNotifyRematchedUpdate

protected Boolean isNotifyRematchedUpdate()

setTriggerNotifyTemplate

public void setTriggerNotifyTemplate(boolean triggerNotifyTemplate)
If using a replicated space controls if the listener that are replicated to cluster members will raise notifications.

See Also:
setReplicateNotifyTemplate(boolean)

isTriggerNotifyTemplate

protected Boolean isTriggerNotifyTemplate()

setReplicateNotifyTemplate

public void setReplicateNotifyTemplate(boolean replicateNotifyTemplate)
If using a replicated space controls if the listener will be replicated between all the replicated cluster members.

If working directly with a cluster member, the default value will be false. Otherwise, the default value will be based on the cluster schema (which is true for clusters with backups).

See Also:
setTriggerNotifyTemplate(boolean)

isReplicateNotifyTemplate

protected Boolean isReplicateNotifyTemplate()

setGuaranteed

@Deprecated
public void setGuaranteed(Boolean guaranteed)
Deprecated. Since 9.0 use setDurable(Boolean) instead.

Controls if notifications will be guaranteed (at least once) in case of failover.


isGuaranteed

protected Boolean isGuaranteed()

setDurable

public void setDurable(Boolean durable)
Controls if notifications will sustain disconnections and failover.


isDurable

protected Boolean isDurable()

setPassArrayAsIs

public void setPassArrayAsIs(boolean passArrayAsIs)
When batching is turned on, should the batch of events be passed as an Object[] to the listener. Default to false which means it will be passed one event at a time.


setDynamicTemplate

public void setDynamicTemplate(Object templateProvider)
Description copied from class: AbstractTemplateEventListenerContainer
Called before each take and read polling operation to change the template Overrides any template defined with AbstractTemplateEventListenerContainer.setTemplate(Object)

Overrides:
setDynamicTemplate in class AbstractTemplateEventListenerContainer

isPassArrayAsIs

protected boolean isPassArrayAsIs()

getNotifyWrite

protected Boolean getNotifyWrite()

getNotifyUpdate

protected Boolean getNotifyUpdate()

getNotifyTake

protected Boolean getNotifyTake()

getNotifyLeaseExpire

protected Boolean getNotifyLeaseExpire()

getNotifyUnmatched

protected Boolean getNotifyUnmatched()

getNotifyMatchedUpdate

protected Boolean getNotifyMatchedUpdate()

getNotifyRematchedUpdate

protected Boolean getNotifyRematchedUpdate()

isBatchEnabled

protected boolean isBatchEnabled()
Returns true when batching is enabled.


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)

validateConfiguration

protected void validateConfiguration()
Description copied from class: AbstractSpaceListeningContainer
Validate the configuration of this container.

Overrides:
validateConfiguration in class AbstractTransactionalEventListenerContainer

createEventSessionConfig

protected EventSessionConfig createEventSessionConfig()
                                               throws IllegalArgumentException
Creates a new EventSessionConfig based on the different parameters this container accepts.

Throws:
IllegalArgumentException

registerListener

protected EventRegistration registerListener(DataEventSession dataEventSession,
                                             RemoteEventListener listener)
                                      throws NotifyListenerRegistrationException
Registers a listener using the provided DataEventSession and based on different parameters set on this container.

Throws:
NotifyListenerRegistrationException

invokeListenerWithTransaction

protected void invokeListenerWithTransaction(BatchRemoteEvent batchRemoteEvent,
                                             boolean performTakeOnNotify,
                                             boolean ignoreEventOnNullTake)
                                      throws DataAccessException
Throws:
DataAccessException

invokeListenerWithTransaction

protected void invokeListenerWithTransaction(Object eventData,
                                             Object source,
                                             boolean performTakeOnNotify,
                                             boolean ignoreEventOnNullTake)
                                      throws DataAccessException
Executes the given listener. If a AbstractTransactionalEventListenerContainer.setTransactionManager(PlatformTransactionManager) is provided will perform the listener execution within a transaction, if not, the listener execution is performed without a transaction.

If the performTakeOnNotify flag is set to true will also perform take operation with the given event data (i.e. remove it from the space).

Parameters:
eventData - The event data object
source - The remote notify event
performTakeOnNotify - A flag indicating whether to perform take operation with the given event data
Throws:
DataAccessException

GigaSpaces XAP 10.0.1 API

Copyright © GigaSpaces.