public class SubscribingEventProcessor extends AbstractEventProcessor implements Lifecycle
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.
Modifier and Type | Class and Description |
---|---|
static class |
SubscribingEventProcessor.Builder
Builder class to instantiate a
SubscribingEventProcessor . |
Lifecycle.LifecycleHandler, Lifecycle.LifecycleRegistry
spanFactory
Modifier | Constructor and Description |
---|---|
protected |
SubscribingEventProcessor(SubscribingEventProcessor.Builder builder)
Instantiate a
SubscribingEventProcessor based on the fields contained in the SubscribingEventProcessor.Builder . |
Modifier and Type | Method and Description |
---|---|
static SubscribingEventProcessor.Builder |
builder()
Instantiate a Builder to be able to create a
SubscribingEventProcessor . |
SubscribableMessageSource<? extends EventMessage<?>> |
getMessageSource()
Returns the message source from which this processor receives its events
|
boolean |
isError()
Indicates whether the processor has been shut down due to an error.
|
boolean |
isRunning()
Indicates whether this processor is currently running (i.e.
|
protected void |
process(List<? extends EventMessage<?>> eventMessages)
Process the given messages.
|
void |
registerLifecycleHandlers(Lifecycle.LifecycleRegistry handle)
Registers the activities to be executed in the various phases of an application's lifecycle.
|
void |
shutDown()
Shut down this processor.
|
void |
start()
Start this processor.
|
canHandle, canHandleType, eventHandlerInvoker, getHandlerInterceptors, getName, processInUnitOfWork, processInUnitOfWork, registerHandlerInterceptor, reportIgnored, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
shutdownAsync
protected SubscribingEventProcessor(SubscribingEventProcessor.Builder builder)
SubscribingEventProcessor
based on the fields contained in the SubscribingEventProcessor.Builder
.
Will assert that the Event Processor name
, EventHandlerInvoker
and
SubscribableMessageSource
are not null
, and will throw an AxonConfigurationException
if
any of them is null
.
builder
- the SubscribingEventProcessor.Builder
used to instantiate a SubscribingEventProcessor
instancepublic static SubscribingEventProcessor.Builder builder()
SubscribingEventProcessor
.
The RollbackConfigurationType
defaults to a RollbackConfigurationType.ANY_THROWABLE
, the
ErrorHandler
is defaulted to a PropagatingErrorHandler
, the MessageMonitor
defaults to a
NoOpMessageMonitor
, the EventProcessingStrategy
defaults to a
DirectEventProcessingStrategy
, the EventProcessorSpanFactory
defaults to a
DefaultEventProcessorSpanFactory
backed by a NoOpSpanFactory
, and the
TransactionManager
defaults to the NoTransactionManager.INSTANCE
. The Event Processor
name
, EventHandlerInvoker
and SubscribableMessageSource
are hard requirements and
as such should be provided.
SubscribingEventProcessor
public void registerLifecycleHandlers(@Nonnull Lifecycle.LifecycleRegistry handle)
Lifecycle
registerLifecycleHandlers
in interface Lifecycle
handle
- the lifecycle instance to register the handlers withLifecycle.LifecycleRegistry.onShutdown(int, Runnable)
,
LifecycleRegistry#onShutdown(int, LifecycleHandler)
,
Lifecycle.LifecycleRegistry.onStart(int, Runnable)
,
LifecycleRegistry#onStart(int, LifecycleHandler)
public void start()
EventBus
.
Upon start up of an application, this method will be invoked in the Phase.LOCAL_MESSAGE_HANDLER_REGISTRATIONS
phase.
start
in interface EventProcessor
public boolean isRunning()
EventProcessor
isRunning
in interface EventProcessor
true
when running, otherwise false
public boolean isError()
EventProcessor
Note that this method returns false
when the processor was stopped using EventProcessor.shutDown()
.
isError
in interface EventProcessor
true
when paused due to an error, otherwise false
protected void process(List<? extends EventMessage<?>> eventMessages)
This implementation creates a Batching unit of work for the given batch of eventMessages
.
eventMessages
- The messages to processpublic void shutDown()
EventBus
.
Upon shutdown of an application, this method will be invoked in the Phase.LOCAL_MESSAGE_HANDLER_REGISTRATIONS
phase.
shutDown
in interface EventProcessor
public SubscribableMessageSource<? extends EventMessage<?>> getMessageSource()
Copyright © 2010–2024. All rights reserved.