|
GigaSpaces XAP 9.7.2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openspaces.events.AbstractSpaceListeningContainer org.openspaces.events.AbstractEventListenerContainer org.openspaces.events.AbstractTemplateEventListenerContainer org.openspaces.events.AbstractTransactionalEventListenerContainer org.openspaces.events.polling.AbstractPollingEventListenerContainer
public abstract class AbstractPollingEventListenerContainer
Base class for listener container implementations which are based on polling. Provides support for listener handling based on Space take operations.
This listener container variant is built for repeated polling attempts, each invoking the
receiveAndExecute(org.openspaces.events.SpaceDataEventListener)
method. The receive timeout for each attempt can be configured through
the "receiveTimeout"
property.
The container allows to set the template object used for the operations. Note, this can be a Pojo
based template, or one of GigaSpace's query classes such as
SQLQuery
.
A pluggable receive operation handler can be provided by setting
setReceiveOperationHandler(org.openspaces.events.polling.receive.ReceiveOperationHandler)
.
The default handler used it
SingleTakeReceiveOperationHandler
.
Event reception and listener execution can automatically be wrapped in transactions through
passing a Spring PlatformTransactionManager
into the
transactionManager
property. This will usually be a
LocalJiniTransactionManager
.
This base class does not assume any specific mechanism for asynchronous execution of polling
invokers. Check out SimplePollingEventListenerContainer
for a concrete implementation
which is based on Spring's TaskExecutor
abstraction,
including dynamic scaling of concurrent consumers and automatic self recovery.
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.
An advance feature allows for pluggable
triggerOperationHandler
which mainly makes sense when using transactions. The trigger operations handler allows to
perform a trigger receive outside of a transaction scope, and if it returned a value, perform the
take within a transaction. A useful implementation of it is
ReadTriggerOperationHandler
.
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 | |
---|---|
AbstractPollingEventListenerContainer()
|
Method Summary | |
---|---|
protected boolean |
doReceiveAndExecute(SpaceDataEventListener eventListener,
Object template,
TransactionStatus status)
|
protected void |
eventReceived(Object event)
Template method that gets called right when a new message has been received, before attempting to process it. |
protected ReceiveOperationHandler |
getReceiveOperationHandler()
|
protected long |
getReceiveTimeout()
Returns the timeout used for receive calls, in millisecond. |
protected TriggerOperationHandler |
getTriggerOperationHandler()
|
void |
initialize()
Initialize this container. |
protected boolean |
isPassArrayAsIs()
|
protected boolean |
receiveAndExecute(SpaceDataEventListener eventListener)
Execute the listener for a message received from the given consumer, wrapping the entire operation in an external transaction if demanded. |
protected Object |
receiveEvent(Object template)
Receive an event |
void |
setPassArrayAsIs(boolean passArrayAsIs)
If set to true will pass an array value returned from a
ReceiveOperationHandler
directly to the listener without "serializing" it as one array element
each time. |
void |
setReceiveOperationHandler(ReceiveOperationHandler receiveOperationHandler)
Allows to set a receive operation handler that will perform the actual receive operation. |
void |
setReceiveTimeout(long receiveTimeout)
Set the timeout to use for receive calls, in milliseconds. |
void |
setTriggerOperationHandler(TriggerOperationHandler triggerOperationHandler)
An advance feature allows for pluggable triggerOperationHandler which mainly makes sense when using
transactions. |
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, 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, 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 |
---|
public static final long DEFAULT_RECEIVE_TIMEOUT
Constructor Detail |
---|
public AbstractPollingEventListenerContainer()
Method Detail |
---|
protected void validateConfiguration()
AbstractSpaceListeningContainer
validateConfiguration
in class AbstractTransactionalEventListenerContainer
public void setPassArrayAsIs(boolean passArrayAsIs)
true
will pass an array value returned from a
ReceiveOperationHandler
directly to the listener without "serializing" it as one array element
each time. Defaults to false
protected boolean isPassArrayAsIs()
public void setReceiveTimeout(long receiveTimeout)
NOTE: This value needs to be smaller than the transaction timeout used by the transaction manager (in the appropriate unit, of course).
GigaSpace.take(Object,long)
protected long getReceiveTimeout()
public void setReceiveOperationHandler(ReceiveOperationHandler receiveOperationHandler)
SingleTakeReceiveOperationHandler
.
protected ReceiveOperationHandler getReceiveOperationHandler()
public void setTriggerOperationHandler(TriggerOperationHandler triggerOperationHandler)
triggerOperationHandler
which mainly makes sense when using
transactions. The trigger operations handler allows to perform a trigger receive outside of a
transaction scope, and if it returned a value, perform the take within a transaction. A
useful implementation of it is
ReadTriggerOperationHandler
. Defaults to
null
.
protected TriggerOperationHandler getTriggerOperationHandler()
public void initialize()
AbstractSpaceListeningContainer
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.
initialize
in class AbstractTransactionalEventListenerContainer
AbstractSpaceListeningContainer.onApplicationEvent(org.springframework.context.ApplicationEvent)
protected boolean receiveAndExecute(SpaceDataEventListener eventListener) throws Throwable, TransactionException
Throwable
TransactionException
doReceiveAndExecute(org.openspaces.events.SpaceDataEventListener, java.lang.Object, org.springframework.transaction.TransactionStatus)
protected boolean doReceiveAndExecute(SpaceDataEventListener eventListener, Object template, TransactionStatus status)
protected Object receiveEvent(Object template) throws DataAccessException
DataAccessException
protected void eventReceived(Object event)
|
GigaSpaces XAP 9.7.2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |