Class SubscribingEventProcessor
- All Implemented Interfaces:
EventProcessor,Lifecycle,MessageHandlerInterceptorSupport<EventMessage<?>>
subscribes to the EventBus for
events. Events published on the event bus are supplied to this processor in the publishing thread.
Depending on the given EventProcessingStrategy the events are processed directly (in the publishing thread)
or asynchronously.
- Since:
- 3.0
- Author:
- Rene de Waele
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aSubscribingEventProcessor.Nested classes/interfaces inherited from interface org.axonframework.lifecycle.Lifecycle
Lifecycle.LifecycleHandler, Lifecycle.LifecycleRegistry -
Field Summary
Fields inherited from class org.axonframework.eventhandling.AbstractEventProcessor
spanFactory -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aSubscribingEventProcessorbased on the fields contained in theSubscribingEventProcessor.Builder. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Instantiate a Builder to be able to create aSubscribingEventProcessor.SubscribableMessageSource<? extends EventMessage<?>> Returns the message source from which this processor receives its eventsbooleanisError()Indicates whether the processor has been shut down due to an error.booleanIndicates whether this processor is currently running (i.e. consuming events from its message source).protected voidprocess(List<? extends EventMessage<?>> eventMessages) Process the given messages.voidRegisters the activities to be executed in the various phases of an application's lifecycle.voidshutDown()Shut down this processor.voidstart()Start this processor.Methods inherited from class org.axonframework.eventhandling.AbstractEventProcessor
canHandle, canHandleType, eventHandlerInvoker, getHandlerInterceptors, getName, processInUnitOfWork, processInUnitOfWork, registerHandlerInterceptor, reportIgnored, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.eventhandling.EventProcessor
shutdownAsync
-
Constructor Details
-
SubscribingEventProcessor
Instantiate aSubscribingEventProcessorbased on the fields contained in theSubscribingEventProcessor.Builder.Will assert that the Event Processor
name,EventHandlerInvokerandSubscribableMessageSourceare notnull, and will throw anAxonConfigurationExceptionif any of them isnull.- Parameters:
builder- theSubscribingEventProcessor.Builderused to instantiate aSubscribingEventProcessorinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aSubscribingEventProcessor.The
RollbackConfigurationTypedefaults to aRollbackConfigurationType.ANY_THROWABLE, theErrorHandleris defaulted to aPropagatingErrorHandler, theMessageMonitordefaults to aNoOpMessageMonitor, theEventProcessingStrategydefaults to aDirectEventProcessingStrategy, theEventProcessorSpanFactorydefaults to aDefaultEventProcessorSpanFactorybacked by aNoOpSpanFactory, and theTransactionManagerdefaults to theNoTransactionManager.INSTANCE. The Event Processorname,EventHandlerInvokerandSubscribableMessageSourceare hard requirements and as such should be provided.- Returns:
- a Builder to be able to create a
SubscribingEventProcessor
-
registerLifecycleHandlers
Description copied from interface:LifecycleRegisters the activities to be executed in the various phases of an application's lifecycle. This could either be at startup, shutdown, or both.- Specified by:
registerLifecycleHandlersin interfaceLifecycle- Parameters:
handle- the lifecycle instance to register the handlers with- See Also:
-
start
public void start()Start this processor. This will register the processor with theEventBus.Upon start up of an application, this method will be invoked in the
Phase.LOCAL_MESSAGE_HANDLER_REGISTRATIONSphase.- Specified by:
startin interfaceEventProcessor
-
isRunning
public boolean isRunning()Description copied from interface:EventProcessorIndicates whether this processor is currently running (i.e. consuming events from its message source).- Specified by:
isRunningin interfaceEventProcessor- Returns:
truewhen running, otherwisefalse
-
isError
public boolean isError()Description copied from interface:EventProcessorIndicates whether the processor has been shut down due to an error. In such case, the processor has forcefully shut down, as it wasn't able to automatically recover.Note that this method returns
falsewhen the processor was stopped usingEventProcessor.shutDown().- Specified by:
isErrorin interfaceEventProcessor- Returns:
truewhen paused due to an error, otherwisefalse
-
process
Process the given messages. A Unit of Work must be created for this processing.This implementation first filters the given
eventMessagesto only include messages that can be handled by the configuredEventHandlerInvoker. Messages that cannot be handled are reported as ignored viaAbstractEventProcessor.reportIgnored(EventMessage), notifying any configuredMessageMonitor.If there are messages that can be handled, a
BatchingUnitOfWorkis created for the filtered batch and processing is delegated to it.- Parameters:
eventMessages- The messages to process.
-
shutDown
public void shutDown()Shut down this processor. This will deregister the processor with theEventBus.Upon shutdown of an application, this method will be invoked in the
Phase.LOCAL_MESSAGE_HANDLER_REGISTRATIONSphase.- Specified by:
shutDownin interfaceEventProcessor
-
getMessageSource
Returns the message source from which this processor receives its events- Returns:
- the MessageSource from which the processor receives its events
-