public final class AepEngine extends RootObject implements IStoreEventHandler, IEventHandler, IEventSource
Modifier and Type | Class and Description |
---|---|
static class |
AepEngine.AppExceptionHandlingPolicy
Enumerates an engine's application exception handling policy.
|
static class |
AepEngine.EventMultiplexerType
Enumerates an engine's supported event multiplexer types
|
static class |
AepEngine.HAPolicy
Enumerates an engine's supported HA policies
|
static class |
AepEngine.InboundEventAcknowledgementPolicy
Enumerates an engine's inbound event acknowledgement policy.
|
static class |
AepEngine.InboundMessageLoggingFailurePolicy
Enumerates policies for handling inbound message logging failures.
|
static class |
AepEngine.InboundMessageLoggingPolicy
Enumerates an engine's inbound message logging policy.
|
static class |
AepEngine.MessageBusBindingFailPolicy
Enumerates an engine's message bus binding fail policy.
|
static class |
AepEngine.MessageHandlingPolicy
Enumerates an engine's inbound message handling policy
|
static class |
AepEngine.MessageSendExceptionHandlingPolicy
Enumerates an engine's message send exception handling policy.
|
static class |
AepEngine.MessageSendPolicy
Deprecated.
|
static class |
AepEngine.MessageSendStabilityFailureHandlingPolicy
Enumerates an engine's message send stability failure handling policy.
|
static class |
AepEngine.MessagingStartFailPolicy
Enumerates an engine's messaging start fail policy.
|
static class |
AepEngine.MessagingState
Enumerates an AEP engine's messaging state.
|
static class |
AepEngine.OutboundMessageLoggingFailurePolicy
Enumerates policies for handling outbound message logging failures.
|
static class |
AepEngine.OutboundMessageLoggingPolicy
Enumerates an engine's outbound message logging policy.
|
static class |
AepEngine.PerTransactionStatsLoggingFailurePolicy
Enumerates policies for handling transaction stats logging failures.
|
static class |
AepEngine.PerTransactionStatsLoggingPolicy
Enumerates an engine's transaction stats logging policy.
|
static class |
AepEngine.ReplicationPolicy
Enumerates an engine's supported replication policies
|
static class |
AepEngine.StartupExpectation
Enumerates the set of startup expectations that can be requested.
|
static class |
AepEngine.State
Enumerates an AEP engine's state.
|
Modifier and Type | Field and Description |
---|---|
String |
CLIENT_BUS_NAME |
static String |
DEFAULT_CHANNEL_KEY
The default channel key
|
static String |
DEFAULT_CHANNEL_NAME
Name of the default channel in each bus
|
static String |
DEFAULT_CHANNEL_ROUTING_KEY
Name of the routing key field of the default channel key
|
static String |
STATS_INTERVAL_PROPNAME
Property controlling whether or not the engine's stats dump thread is enabled.
|
static String |
SYSTATS_INTERVAL_PROPNAME
Property controlling whether or not the engine's sys stats dump thread is enabled.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelSchedule(AepScheduleEvent event)
Cancel the dispatch of a scheduled event.
|
static AepEngine |
create(AepEngineDescriptor engineDescriptor,
IAepApplicationStateFactory stateFactory,
Set<Object> eventHandlerContainers,
IEventHandler defaultEventHandler,
Collection<AepMessageSender> messageSenders,
IAepWatcher watcher)
Create an AEP engine.
|
static AepEngine |
create(AepEngineDescriptor engineDescriptor,
IAepApplicationStateFactory stateFactory,
Set<Object> eventHandlerContainers,
IEventHandler defaultEventHandler,
IAepWatcher watcher)
Create an AEP engine.
|
<K,T extends IStoreObject> |
createStoreNonUniqueIndex(String fieldPath,
String name)
Creates non-unique index on store data.
|
<K,T extends IStoreObject> |
createStoreUniqueIndex(String fieldPath,
String name)
Creates unique index on store data.
|
int |
createTransactionSavepoint()
Creates a savepoint in the current transaction.
|
boolean |
dropStoreIndex(IStoreIndex<?,? extends IStoreObject> indexView)
Drops created index.
|
boolean |
dropStoreIndex(String fieldPath)
Drops created store index.
|
boolean |
dropStoreIndexByName(String name)
Drops created index.
|
AepEngine.AppExceptionHandlingPolicy |
getAppExceptionHandlingPolicy()
Get an engine's application exception handling policy.
|
<T> T |
getApplicationState(int flowid)
Get the application state associated with a flow.
|
<T> T |
getApplicationState(MessageView message)
Get the application state associated with an inbound message.
|
Collection<AepBusManager> |
getBusManagers()
Get an engine's bus managers.
|
MessageBusBinding |
getClientBusBinding()
Get an application's 'client' message bus binding.
|
IRogMessage |
getCurrentMessage()
Returns the message currently being dispatch by the engine.
|
AepEngineDescriptor |
getDescriptor()
Get an engine's descriptor.
|
long |
getEngineTime()
Get current engine time.
|
long |
getEngineTimeMicros()
Get current engine time.
|
AepEventDispatcher |
getEventDispatcher()
Get an engine's event dispatcher
|
IEventMultiplexer |
getEventMultiplexer()
Get an engine's event multiplexer.
|
AepEngine.EventMultiplexerType |
getEventMultiplexerType()
Get an engine's event multiplexer type.
|
AepEngine.HAPolicy |
getHAPolicy()
Get an engine's HA policy.
|
IRogMessageLogger |
getInboundMessageLogger()
Get an engine's inbound message logger.
|
AepEngine.InboundMessageLoggingPolicy |
getInboundMessageLoggingPolicy()
Get an engine's inbound message logging policy.
|
AepEngine.MessageBusBindingFailPolicy |
getMessageBusBindingFailPolicy()
Get an engine's message bus binding fail policy.
|
AepEngine.MessageHandlingPolicy |
getMessageHandlingPolicy()
Get an engine's message handling policy.
|
AepEngine.MessageSendExceptionHandlingPolicy |
getMessageSendExceptionHandlingPolicy()
Get an engine's message send exception handling policy.
|
AepEngine.MessageSendStabilityFailureHandlingPolicy |
getMessageSendStabilityFailureHandlingPolicy()
Get an engine's message send stability failure handling policy.
|
AepEngine.MessagingStartFailPolicy |
getMessagingStartFailPolicy()
Get an engine's messaging start fail policy.
|
AepEngine.MessagingState |
getMessagingState()
Get an engine's messaging state.
|
String |
getName()
Implementation of
IEventSource.getName() |
IRogMessageLogger |
getOutboundMessageLogger()
Get an engine's outbound message logger.
|
AepEngine.OutboundMessageLoggingPolicy |
getOutboundMessageLoggingPolicy()
Get an engine's outbound message logging policy.
|
AepEngine.ReplicationPolicy |
getReplicationPolicy()
Get an engine's replication policy.
|
AepEngine.State |
getState()
Get an engine's state.
|
IAepEngineStats |
getStats()
Get the set of a engine's operational statistics.
|
IStoreBinding |
getStore()
Get an engine's operational store.
|
<K,T extends IStoreObject> |
getStoreNonUniqueIndex(String fieldPath)
Retrieves non-unique store index by field path.
|
<K,T extends IStoreObject> |
getStoreUniqueIndex(String fieldPath)
Retrieves unique store index by field path.
|
int |
getTransactionSavepoint()
Get the current savepoint for the transaction.
|
void |
injectMessage(IRogMessage message)
Enqueue a message into this
AepEngine 's event multiplexer. |
void |
injectMessage(IRogMessage message,
boolean nonBlocking)
Enqueue a message into this
AepEngine 's event multiplexer. |
void |
injectMessage(IRogMessage message,
boolean nonBlocking,
IEventAcknowledger acknowledger)
Enqueue a message into this
AepEngine 's event multiplexer. |
void |
injectMessage(IRogMessage message,
boolean nonBlocking,
int delay)
Enqueue a message into this
AepEngine 's event multiplexer. |
void |
injectMessage(IRogMessage message,
boolean nonBlocking,
int delay,
IEventAcknowledger acknowledger)
Enqueue a message into this
AepEngine 's event multiplexer. |
void |
injectMessage(IRogMessage message,
IEventAcknowledger acknowledger)
Enqueue a message into this
AepEngine 's event multiplexer. |
boolean |
isClustered()
Get if an engine is running in clustered or non-clustered mode.
|
boolean |
isDispatchThread()
Tests if the current thread is currently dispatching an
AepEngine event. |
boolean |
isMessageDispatchThread()
Tests if the current thread is currently dispatching a message.
|
boolean |
isPersistent()
Get if an engine is running in persistent or non-persistent mode.
|
boolean |
isPrimary()
Get if the engine is running as primary or secondary.
|
void |
multiplexMessage(IRogMessage message)
Deprecated.
This method is deprecated by
injectMessage(IRogMessage) |
void |
multiplexMessage(IRogMessage message,
boolean nonBlocking)
Deprecated.
This method is deprecated by
injectMessage(IRogMessage, boolean) |
void |
onEvent(Event event)
Implementation of
IEventHandler.onEvent(com.neeve.event.Event)
This method is the engine multiplexer's event handler, it should never be invoked
directly by the application. |
void |
onEvent(IStoreEvent event)
Implementation of
IStoreEventHandler.onEvent(com.neeve.ods.IStoreEvent)
This method is the store event handler and should never be invoked
directly by the application. |
void |
registerCounterStat(IStats.Counter counter)
Registers a user counter stat with the engine stats.
|
AepEngine |
registerEnvironmentProvider(IAepEnvironmentProvider provider)
Register an environment provider.
|
AepEngine |
registerFactory(Object factory)
Register a factory.
|
void |
registerGaugeStat(IStats.Gauge gauge)
Registers a user Gauge stat with the engine stats.
|
AepEngine |
registerMessageFactory(MessageViewFactory factory)
Register a message factory.
|
AepEngine |
registerObjectFactory(IStoreObjectFactory factory)
Register an object factory
|
void |
registerSeriesStat(IStats.Series series)
Registers a user latency stat with the engine stats.
|
AepEngine |
registerTypeFactory(com.neeve.sto.StoTypeFactory factory)
Register a type factory.
|
void |
replyToClient(MessageChannel channel,
PktPacket request,
PktPacket reply,
int replyCount,
int replyNum)
Send a success reply to a client request.
|
void |
replyToClientWithError(MessageChannel channel,
PktPacket request,
PktPacket reply,
long errorCode)
Send an error reply to a client request.
|
void |
resumeCommit(AepTransactionStageEvent.ICommitContext context)
Resume a suspended transaction commit.
|
void |
rollbackToTransactionSavepoint(int savepoint)
Rolls back state changes and outbound messages to a given savepoint.
|
AepScheduleEvent |
scheduleMessage(IRogMessage message)
Schedule a message for immediate dispatch.
|
AepScheduleEvent |
scheduleMessage(IRogMessage message,
int delay)
Schedule a message for a (one-time) delayed dispatch with the
default schedule HA policy.
|
AepScheduleEvent |
scheduleMessage(IRogMessage message,
int delay,
AepScheduleEvent.HAPolicy haPolicy)
Schedule a message for (one-time) delayed dispatch.
|
AepScheduleEvent |
scheduleObject(Object object)
Schedule an opaque object for immediate dispatch.
|
AepScheduleEvent |
scheduleObject(Object object,
int interval)
Schedule an opaque object for periodic dispatch with the default schedule HA policy.
|
AepScheduleEvent |
scheduleObject(Object object,
int interval,
AepScheduleEvent.HAPolicy haPolicy)
Schedule an opaque object for periodic dispatch at a specified interval.
|
void |
sendMessage(MessageChannel channel,
IRogMessage message)
Send an outbound message.
|
void |
sendMessage(MessageChannel channel,
IRogMessage message,
MessageChannel.RawKeyResolutionTable keyResolutionTable)
Send a message using a
XString key resolution table. |
void |
sendMessage(MessageChannel channel,
IRogMessage message,
Properties keyResolutionTable)
Send a message.
|
void |
sendMessage(MessageChannel channel,
IRogMessage message,
String key,
Properties keyResolutionTable)
Send an outbound message.
|
void |
sendMessage(MessageChannel channel,
IRogMessage message,
XString key,
MessageChannel.RawKeyResolutionTable keyResolutionTable)
Send an outbound message.
|
void |
setAppExceptionHandlingPolicy(AepEngine.AppExceptionHandlingPolicy policy)
Set an engine's application exception handling policy.
|
void |
setAsLastTransaction(Exception cause,
boolean ignoreIfStarting)
Set current transaction as last transction (only for primary agent)
This method invoked
setAsLastTransaction(cause, ignoreIfStarting, false)
|
void |
setAsLastTransaction(Exception cause,
boolean ignoreIfStarting,
boolean shutdownCluster)
Set current transaction as the last transaction.
|
void |
setAsynchronousEventHandler(IAepAsynchronousEventHandler handler)
Sets the handler for asynchronous engine events.
|
void |
setCentralMessageHandler(IAepPredispatchMessageHandler handler)
Deprecated.
|
void |
setMessageFilter(MessageViewFilter messageFilter)
Sets a MessageFilter for live messages received by an
AepEngine operating
in the primary role. |
void |
setMessageHandlingPolicy(AepEngine.MessageHandlingPolicy policy)
Set an engine's message handling policy.
|
void |
setMessageSendExceptionHandlingPolicy(AepEngine.MessageSendExceptionHandlingPolicy policy)
Set an engine's message send exception handling policy.
|
void |
setMessageSendStabilityFailureHandlingPolicy(AepEngine.MessageSendStabilityFailureHandlingPolicy policy)
Set an engine's message send stability failure handling policy.
|
IAepPostdispatchMessageHandler |
setPostdispatchMessageHandler(IAepPostdispatchMessageHandler handler)
Register the central post dispatch message handler.
|
IAepPredispatchMessageHandler |
setPredispatchMessageHandler(IAepPredispatchMessageHandler handler)
Register the pre dispatch message handler.
|
void |
start()
Start an AEP engine.
|
void |
start(Map<AepEngine.StartupExpectation,Enum<?>> expectations)
Deprecated.
This method has been deprecated. Startup expectations should be set in the
engine's descriptor rather than supplied to this start method
|
void |
startBusManager(String name)
Start an engine bus manager
|
void |
stop()
Stop an AEP engine (normal).
|
void |
stop(Exception cause)
Stop an AEP engine.
|
void |
waitForMessagingToStart()
Wait for messaging to be started.
|
getChecked, getThreaded, getTracer, setChecked, setTracer
public final String CLIENT_BUS_NAME
public static final String DEFAULT_CHANNEL_NAME
public static final String DEFAULT_CHANNEL_ROUTING_KEY
public static final String DEFAULT_CHANNEL_KEY
public static final String STATS_INTERVAL_PROPNAME
Can be set to a postive integer indicate the period in seconds at which the engine's stats dump thread will dump recorded engine statistics. Setting a value of 0 disables creation of the stats thread.
When enabled engine stats are traced to the logger 'nv.aep.engine.stats' at a level
of Tracer.Level.INFO
, so to see dumped stats a trace level of 'nv.aep.engine.stats.trace=info'
must be enabled.
NOTE:: disabling the engine stats thread only stops stats from being periodically traced. It does not stop the engine from collecting stats ... stats can still be collected by an external thread (such as the Talon Server which reports the stats in server heartbeats). In other words enabling the stats thread is not a prerequisite for collecting stats, and disabling the stats reporting thread does not stop them from being collected.
NOTE: that while collection of engine stats is a zero garbage operation, tracing engine stats is not a zero garbage when performed by this stats thread. For latency sensitive apps it is recommended to run in a Talon server which can collect engine stats and report them in heartbeats in a zero garbage fashion.
public static final String SYSTATS_INTERVAL_PROPNAME
Can be set to a postive integer indicate the period in seconds at which the system stats are traced.
When enabled engine stats are traced to the logger 'nv.aep.aep.engine.systats', at a level of 'debug', so to see dumped stats a trace level of 'nv.aep.aep.engine.systats.trace=info' must be enabled.
System stats printing is useful when not executing in a Talon server, but in most cases, it makes more sense to use server stats to report system stats, so in practice this property will not generally be used.
NOTE: tracing system stats is not a zero garbage when performed by this stats thread. For latency sensitive apps it is recommended to run in a Talon server which can collect system stats and report them in heartbeats in a near zero garbage fashion.
public static final AepEngine create(AepEngineDescriptor engineDescriptor, IAepApplicationStateFactory stateFactory, Set<Object> eventHandlerContainers, IEventHandler defaultEventHandler, Collection<AepMessageSender> messageSenders, IAepWatcher watcher)
engineDescriptor
- A descriptor object containing messaging and
persistence information of interest to the application. In particular,
the descriptor specifies the SMA messaging buses and channels of interest
to the application and the ODS store to join.stateFactory
- The application's state factory interface. This is
the interface used by the AEP engine to create application state instances
that it attaches to each inbound message flow. A value of null indicates
that the application does not want the AEP engine to store application
state. If the application specifies null in this parameter but specifies
an ODS store in the engine descriptor, the engine will store messaging
state in the ODS store to ensure exactly once delivery on failover.eventHandlerContainers
- This parameer specifies the set of objects
in the application that implement the message and event handlers. On
creation, the engine walks through these objects and identifies handlers
that are annotated with EventHandler
.defaultEventHandler
- This parameter identifies the application's
default event handler. Inbound events that do not match an annotated
handler are passed to this handler. This parameter can be null.messageSenders
- The set of message senders to register with the
engine. The engine will add these senders into the event handler container
list.watcher
- This parameter specifies a watcher object. The AEP engine
dispatches significant operational events to the watcher through the
course of its operation. This parameter can be null.public static final AepEngine create(AepEngineDescriptor engineDescriptor, IAepApplicationStateFactory stateFactory, Set<Object> eventHandlerContainers, IEventHandler defaultEventHandler, IAepWatcher watcher)
This method invokes create(engineDescriptor, stateFactory, eventHandlerContainers, defaultEventHandler, null, watcher)
public final AepEventDispatcher getEventDispatcher()
public final AepEngineDescriptor getDescriptor()
This method returns the descriptor using which the engine was created.
public final boolean isClustered()
An engine is considered to operate in clustered mode if and only if it is configured to attach to a store and the store is operating in clustered mode.
public final boolean isPersistent()
An engine is considered to operate in persistent mode if and only if it is configured to attach to a store and the store is operating in persistent mode.
public final AepEngine.HAPolicy getHAPolicy()
public final AepEngine.ReplicationPolicy getReplicationPolicy()
public final AepEngine.MessagingStartFailPolicy getMessagingStartFailPolicy()
public final AepEngine.MessageBusBindingFailPolicy getMessageBusBindingFailPolicy()
public final AepEngine.InboundMessageLoggingPolicy getInboundMessageLoggingPolicy()
public final AepEngine.OutboundMessageLoggingPolicy getOutboundMessageLoggingPolicy()
public final void setMessageHandlingPolicy(AepEngine.MessageHandlingPolicy policy)
This method can be invoked in any state.
policy
- The message handling policy to set.public final AepEngine.MessageHandlingPolicy getMessageHandlingPolicy()
public final void setAppExceptionHandlingPolicy(AepEngine.AppExceptionHandlingPolicy policy)
public final AepEngine.AppExceptionHandlingPolicy getAppExceptionHandlingPolicy()
public final void setMessageSendExceptionHandlingPolicy(AepEngine.MessageSendExceptionHandlingPolicy policy)
public final AepEngine.MessageSendExceptionHandlingPolicy getMessageSendExceptionHandlingPolicy()
public final void setMessageSendStabilityFailureHandlingPolicy(AepEngine.MessageSendStabilityFailureHandlingPolicy policy)
public final AepEngine.MessageSendStabilityFailureHandlingPolicy getMessageSendStabilityFailureHandlingPolicy()
public final AepEngine.EventMultiplexerType getEventMultiplexerType()
public final AepEngine registerMessageFactory(MessageViewFactory factory)
factory
- The message factory to register
This method is a convenience method to programmatically register a
message factory with the SMA runtime. This method is one of the various
mechanisms available to register a message factory with the SMA runtime.
The other two are to configure the factory in the platform repository
or directly invoke MessageViewFactoryRegistry
to install the
factory (which is what this method does). The SMA runtime uses the
collection of all administratively configured and programatically
registered factories to instantiate received application messages.
This method is only permitted on an engine that has not been started.
public final AepEngine registerObjectFactory(IStoreObjectFactory factory)
factory
- The object factory to register
This method is a convenience method to programmatically register an
object factory with the ODS runtime. This method is one of the various
mechanisms available to register a object factory with the ODS runtime.
The other two are to configure the factory in the platform repository
or directly invoke StoreObjectFactoryRegistry
to install the
factory (which is what this method does). The ODS runtime uses the
collection of all administratively configured and programatically
registered factories to instantiate replicated data objects.
This method is only permitted on an engine that has not been started.
public final AepEngine registerTypeFactory(com.neeve.sto.StoTypeFactory factory)
This method is a convenience method to programmatically register a
type factory with the STO runtime. This method is one of the various
mechanisms available to register a type factory with the STO runtime.
The other two are to configure the factory in the platform repository
or directly invoke StoTypeFactoryRegistry
to install the
factory (which is what this method does). The ODS runtime uses the
collection of all administratively configured and programatically
registered factories to instantiate transmitted complex types.
This method is only permitted on an engine that has not been started.
factory
- The type factory to register.public final AepEngine registerFactory(Object factory)
factory
- The factory to register
This method is a convenience methods that detects the type of factory
supplied and appropriately calls registerMessageFactory(com.neeve.sma.MessageViewFactory)
,
registerObjectFactory(com.neeve.ods.IStoreObjectFactory)
and/or registerTypeFactory(com.neeve.sto.StoTypeFactory)
This method is only permitted on an engine that has not been started.
public final AepEngine registerEnvironmentProvider(IAepEnvironmentProvider provider)
This method registers an environment provider with an AEP engine.
This method may not be called on an engine:
AepEngine.State.Init
)
AepEngineDescriptor.getReplicateInParallel()
== false
provider
- The provider to register.IllegalArgumentException
- if the provider is nullIllegalStateException
- if the engine is not in a state that allows environment providers to be registered.public final void registerSeriesStat(IStats.Series series)
series
- The stat to addIllegalStateException
- if the engine has been startedStatsFactory.createSeriesStat(String)
public final void registerCounterStat(IStats.Counter counter)
counter
- The stat to addIllegalStateException
- if the engine has been startedStatsFactory.createCounterStat(String)
public final void registerGaugeStat(IStats.Gauge gauge)
gauge
- The stat to addIllegalStateException
- if the engine has been startedIStats.Gauge
@Deprecated public final void setCentralMessageHandler(IAepPredispatchMessageHandler handler)
setPredispatchMessageHandler(IAepPredispatchMessageHandler)
insteadpublic final IAepPredispatchMessageHandler setPredispatchMessageHandler(IAepPredispatchMessageHandler handler)
This method registers the pre dispatch message handler. The predispatch handler is invoked prior to message/event annotated handlers and the default handler.
This method can be invoked at any point in an engine's lifecycle.
handler
- The handler to register (null to deregister)public final IAepPostdispatchMessageHandler setPostdispatchMessageHandler(IAepPostdispatchMessageHandler handler)
A post dispatch message handler is useful for doing any post message processing book keeping.
The post dispatch handler will not be invoked if an exception is
thrown from either the IAepPredispatchMessageHandler
, or a normal or
default message handler, but an application may register an EventHandler
for AepApplicationExceptionEvent
to be notified that dispatch did not
complete.
This method registers the postdispatch message handler. The postdispatch handler is invoked subsequent to message/event annotated handlers and the default handler.
This method can be invoked at any point in an engine's lifecycle.
handler
- The handler to register (null to deregister)public final void setAsynchronousEventHandler(IAepAsynchronousEventHandler handler)
handler
- The asynchronous event handler.public final void setMessageFilter(MessageViewFilter messageFilter)
AepEngine
operating
in the primary role.
A message filter does not apply to messages replicated by a peer or recovered from disk. Filtered messages are acknowledged, and are not logged to a transaction logs.
Effects of a MessageFilter:
Filtered messages:
This call replaces a currently registered MessageViewFilter
.
Exceptions thrown from a MessageFilter:
If an exception is thrown by a MessageFilter, it is handled according to the
AepEngine.AppExceptionHandlingPolicy
for this engine. If the policy is
AepEngine.AppExceptionHandlingPolicy.LogExceptionAndContinue
, the message is not
dispatched to application handlers and is acknowledged.
messageFilter
- The message filter.@Deprecated public final void start(Map<AepEngine.StartupExpectation,Enum<?>> expectations) throws EAepException
This method starts an engine with the specified set of startup expectations. The specified set of expectations overrides the expectations in the engine's descriptor
EAepException
public final void start() throws EAepException
This method starts an AEP engine. This method needs to be invoked before the engine can be used. The method first opens the engine's store (if the engine is configured to operate in clustered mode) followed by starting the messaging machinery (opening the configured bus bindings) if elected as the cluster primary or if operating in non-clustered mode. If elected as a cluster backup, the method returns immediately and messaging is started when the engine switches to primary.
EAepException
- Thrown if an error is encountered while starting
the engine.public final void waitForMessagingToStart() throws EAepException
This method waits for the AEP engine to start the messaging machinery. For
cluster primaries or standalone engines, the messaging is started by the
start(java.util.Map<com.neeve.aep.AepEngine.StartupExpectation, java.lang.Enum<?>>)
method. For backup engines, messaging is started when the
engine becomes the primary. It is ensured that channel up events for
bus bindings that could be successfully established at the time messaging
is started are dispatched before this method returns.
This method can only be invoked on a started engine
EAepException
public final AepEngine.State getState()
public final AepEngine.MessagingState getMessagingState()
public final IStoreBinding getStore()
This method returns the engine's binding to the operational store configured for use by the engine. A return value of null indicates that no operational store has been configured for use.
This method is permitted on an engine in any state. However, note that a store is only opened when an engine is started. Therefore, one should always be aware of the store and engine's state when working with a store obtained via this method.
public final Collection<AepBusManager> getBusManagers()
This method returns the set of bus managers created by an engine as configured for use by the engine. An empty collection indicates that the engine has not been configured to connect to any messaging bus
This method is permitted on an engine in any state. However, note that bus managers are only opened when an engine goes active i.e. becomes the primary in a cluster. Therefore, one should always be aware of the engine and bus manager's state when working with bus managers obtained via this method.
public final void startBusManager(String name) throws EAepException
name
- The bus manager to start
This method starts an engine bus manager configured for manual start
This method is permitted on an engine in the started state and whose messaging has also been started.
IllegalArgumentException
- Thrown if the supplied name is null
or does not refer to a valid bus managerIllegalStateException
- Thrown if the bus manager is not configured
for manual start, if the engine is not in the started state, engine
messaging is not started and the bus manager is in the failed or closed
state.EAepException
- Thrown if an error is encountered in starting the
bus managerpublic final IEventMultiplexer getEventMultiplexer()
This method returns the inbound event multiplexer used by an engine.
This method is permitted only on a primary engine in the started state. An exception is thrown if invoked on a backup or in any other state.
public final boolean isDispatchThread()
AepEngine
event.
Depending on the EventMultiplexer
type and other factors the dispatch thread
may change from one event to another.
For a given thread this will only return true when called from that thread if the AepEngine is dispatching an event to the application at the time of the call. A return value of true does not necessarily mean that the engine is dipatching a message to the application; this will return true for any event being dispatch to the application from the engine's dispatch thread.
AepEngine
.public final boolean isMessageDispatchThread()
This call is similar to isDispatchThread()
, but additionally checks whether
the thread is dispatching a message (as opposed to another event type).
AepEngine
.public final IRogMessage getCurrentMessage()
This method returns the message currently be dispatched to an application's event handlers. This method is useful in applications that have complex logic in which there are methods to which the application does not pass the message being dispatched.
Note, that the returned message may be stored in a volatile variable, so accessing the message
in this fashion is more expensive than passing the message down through the application's
call stack. Applications that are performance sensitive should not use this method. Applications
that are performance sensitive should instead store the message themselves using
setPredispatchMessageHandler(IAepPredispatchMessageHandler)
and
setPostdispatchMessageHandler(IAepPostdispatchMessageHandler)
and store the message without
the additional thread safety.
AepEngine
.EventHandler
is not supported.public final void injectMessage(IRogMessage message, boolean nonBlocking, int delay, IEventAcknowledger acknowledger)
AepEngine
's event multiplexer.
This method enqueues a message for execution on this engine's event multiplexer event loop and returns to the caller. The message is then dispatched subsequently using the normal message dispatch mechanisms like a message received from a message bus binding.
The differences between this method and scheduleMessage(IRogMessage)
are:
AepEngine.State.Starting
) are similarly ignored
as they would interfere with the stream being replayed. An application that injects messages
from an external source may call waitForMessagingToStart()
to avoid
an injected message being discarded while an engine is transitioning to a started,
primary role.
It is important to note that message injection is thus effectively a BestEffort
operation because injections of message that are in the event multiplexer queue
at the time of failure will be lost. Reliable injection can be achived via
scheduleMessage(IRogMessage, int, com.neeve.aep.AepScheduleEvent.HAPolicy)
though fault tolerant scheduling incurs slight higher overhead.
IRogNode.dispose()
on the message once it has been dispatched,
so an application must call MessageView.acquire()
if it will hold on to
a (read-only) reference to the message.
message
- The IRogMessage to enqueue.nonBlocking
- Indicates whether the multiplexing should be a non-blocking action or
not. If blocking, then the calling thread will block if the main multiplexer queue is full
and wait until space is available. If non-blocking, then the method will not wait but rather
enque the message in a multiplexer feeder queue and return. Note that if this method is called
from the engine's dispatch thread, this parameter is ignored and non blocking enqueue is
used implicitly.delay
- The delay in milliseconds at which the message should be injected.acknowledger
- The acknowledger that will be invoked when the processing of the transaction
containing the injected message is complete. Note that such notifications will only occur on
engines operating in the Primary role. This parameter can be null.IllegalStateException
- Thrown if the method is invoked in any
state other than AepEngine.State.Started
or AepEngine.State.Starting
.public final void injectMessage(IRogMessage message, boolean nonBlocking, int delay)
AepEngine
's event multiplexer.
This method invokes injectMessage(message, nonBlocking, delay, null)
public void injectMessage(IRogMessage message, boolean nonBlocking, IEventAcknowledger acknowledger)
AepEngine
's event multiplexer.
This method invokes injectMessage(message, nonBlocking, 0, acknowledger)
public void injectMessage(IRogMessage message, boolean nonBlocking)
AepEngine
's event multiplexer.
This method invokes injectMessage(message, nonBlocking, 0, null)
public void injectMessage(IRogMessage message, IEventAcknowledger acknowledger)
AepEngine
's event multiplexer.
This method invokes injectMessage(message, false, 0, acknowledger)
public void injectMessage(IRogMessage message)
AepEngine
's event multiplexer.
This method invokes injectMessage(message, false, 0, null)
@Deprecated public final void multiplexMessage(IRogMessage message, boolean nonBlocking)
injectMessage(IRogMessage, boolean)
@Deprecated public final void multiplexMessage(IRogMessage message)
injectMessage(IRogMessage)
public final AepScheduleEvent scheduleMessage(IRogMessage message)
This method is equivalent to invoking
scheduleMessage(message, 0, HAPolicy.Cancel)
.
message
- The message to dispatch.IllegalArgumentException
- Thrown if the supplied message is
null.IllegalStateException
- Thrown if the method is invoked in any
state other than AepEngine.State.Starting
or AepEngine.State.Started
, from
outside of a message, 'messaging started' or schedule event handler or
by a thread other than the one that that invoked the message/event
handler.public final AepScheduleEvent scheduleMessage(IRogMessage message, int delay)
This method is equivalent to invoking
scheduleMessage(message, delay, HAPolicy.Cancel)
.
message
- The message to dispatch.delay
- The delay, in milliseconds, after which to dispatch the
message. A time of <= 0 is interpreted as a request for immediate
dispatch. In this case, this parameter is interpreted as an event
priority in a manner that treats lower numbers as higher priorities.IllegalArgumentException
- Thrown if the supplied message is
null.IllegalStateException
- Thrown if the method is invoked in any
state other than AepEngine.State.Starting
or AepEngine.State.Started
, from
outside of a message, 'messaging started' or schedule event handler or
by a thread other than the one that that invoked the message/event
handler.public final AepScheduleEvent scheduleMessage(IRogMessage message, int delay, AepScheduleEvent.HAPolicy haPolicy)
This method schedules a message with the engine's event multiplexer
for dispatch after a specified delay. The delay is expressed in
milliseconds. A delay of > 0 is interpreted as a request for delayed
dispatch while a value of <= 0 is interpeted as immediate dispatch. The
method instantiates a new schedule, registers the schedule with the engine's
event multiplexer and returns a handle to the schedule in the form of
AepScheduleEvent
. The scheduled message is dispatched to the
application when the schedule fires. When dispatched, the schedule event
is tagged to the message and can be retrieved from the message as follows:
message.getTag(MessageViewTags.TAG_AEP_SCHEDULE_EVENT)
For EventSourced engines, the act of scheduling of and dispatch of the scheduled message is replicated to the backup. Therefore, the during steady state the scheduled message will be dispatched to the application in the same order relative to other messages. Also, activated scheduled persist failover and restart. On failover or restart, schedules are automatically reactivated.
For StateReplication engines, the act of scheduling and dispatch of schedule messages is not persisted or replicated. Therefore, the application needs to reschedule the messages on failover/restart.
This method takes ownership of the scheduled message. This means that the caller should relinquish control of the message until the message is dispatched to the application. Once dispatched, the ownership is transferred to the application.
Note: Upon completion of the message dispatch to the application
or on cancellation of the schedule, the engine disposes the schedule
handle i.e. AepScheduleEvent
. When event pooling is enabled,
the act of disposing the event will clear out its contents. Therefore,
if the application intends to refer to the contents of the event post
dispatch/cancel, the application must acquire a reference to the event
via Event.acquire()
. The acquired reference must be disposed via
Event.dispose()
when the application is done referencing the
event.
message
- The message to dispatch.delay
- The delay, in milliseconds, after which to dispatch the
message. A time of <= 0 is interpreted as a request for immediate
dispatch. In this case, this parameter is interpreted as an event
priority in a manner that treats lower numbers as higher priorities.haPolicy
- Specifies the schedule's HA policy.IllegalArgumentException
- Thrown if the supplied message is
null.IllegalStateException
- Thrown if the method is invoked in any
state other than AepEngine.State.Starting
or AepEngine.State.Started
, from
outside of a message, 'messaging started' or schedule event handler or
by a thread other than the one that that invoked the message/event
handler.public final AepScheduleEvent scheduleObject(Object object)
This method is equivalent to invoking
scheduleObject(message, 0, HAPolicy.Cancel)
.
public final AepScheduleEvent scheduleObject(Object object, int interval)
This method is equivalent to invoking
scheduleObject(message, delay, HAPolicy.Cancel)
.
public final AepScheduleEvent scheduleObject(Object object, int interval, AepScheduleEvent.HAPolicy haPolicy)
This method schedules an object with the engine's event multiplexer
for periodic dispatch at the specified interval. The interval is
expressed in milliseconds. A delay of > 0 is interpreted as a request
for delayed dispatch while a value of <= 0 is interpeted as immediate
dispatch. The method instantiates a new schedule, registers the schedule
with the engine's event multiplexer and returns a handle to the schedule
in the form of AepScheduleEvent
. The returned event is dispatched
to the application each time the schedule fires. The provided object is
encapsulated within the dispatched event.
For EventSourced engines, the act of scheduling of and dispatch of the scheduled object is replicated to the backup. Therefore, during steady state the scheduled object will be dispatched to the application in the same order relative to other messages and events. Also, schedules persist failover and restart i.e. on failover or restart, the schedules are automatically reactivated.
For StateReplication engines, the act of scheduling and dispatch of schedule objects is not persisted or replicated. Therefore, the application needs to reschedule the objects on failover/restart.
Note: Upon completion of the object dispatch to the application
for an imediate dispatch schedule or on cancellation of a periodic
dispatch schedule, the engine disposes the schedule handle i.e.
AepScheduleEvent
. When event pooling is enabled, the act of
disposing the event will clear out its contents. Therefore, if the
application intends to refer to the contents of the event post
dispatch/cancel, the application must acquire a reference to the
event via Event.acquire()
. The acquired reference must be
disposed via Event.dispose()
when the application is done
referencing the event.
interval
- The interval (in milliseconds) at which to dispatch
the object. A value <= 0 is interpreted as a request for one-time
immediate dispatch. In this case, this parameter is interpreted as
an event priority in a manner that treats lower numbers as higher
priorities.object
- The object to dispatch.haPolicy
- Specifies the schedule's HA policy.IllegalStateException
- Thrown if the method is invoked in any
state other than AepEngine.State.Starting
or AepEngine.State.Started
, from
outside of a message, 'messaging started' or schedule event handler or
by a thread other than the one that that invoked the message/event
handler.public final void cancelSchedule(AepScheduleEvent event)
This method cancels the dispatch of a schedule event. If the event is scheduled for perdiodic dispatch, then this method cancels all future dispatch. If scheduled for a single dispatch, then the dispatch is cancelled. The caller is guaranteed that the schedule event will not be dispatched to the caller after successful return from this method.
This method can be safely invoked multiple times.
event
- The schedule to cancel.IllegalStateException
- Thrown if the method is invoked in any
state other than AepEngine.State.Starting
or AepEngine.State.Started
, from
outside of a message, 'messaging started' or schedule event handler or
by a thread other than the one that that invoked the message/event
handler.public final IRogMessageLogger getInboundMessageLogger()
This method returns the inbound message logger used by an engine.
An engine opens it's message loggers when engine is started. Therefore, this method will return null prior to a successful engine start.
The contents of an engine's inbound message log are managed very carefully by the engine. Logging messages using this method is very advanced use and should only be used if absolutely necessary and the caller has deep knowledge of how the engine manages entries in the log.
public final IRogMessageLogger getOutboundMessageLogger()
This method returns the outbound message logger used by an engine.
An engine opens it's message loggers when engine is started. Therefore, this method will return null prior to a successful engine start.
The contents of an engine's outbound message log are managed very carefully by the engine particularly when the engine is configured to use the inbound message logger for outbound messages too. Logging messages using this method is very advanced use and should only be used if absolutely necessary and the caller has deep knowledge of how the engine manages entries in the log.
public final boolean isPrimary()
The method will return true if operating in a non-clustered
(standalone) mode. To differentiate between a primary in a
cluster or running in standalone mode, use isClustered()
This method is permitted only in any state except init or stopped state. An exception is thrown if invoked in any other state.
IllegalStateException
- if the the engine is not in Starting, Started or Stopping state.public final MessageBusBinding getClientBusBinding()
An engine starts its messaging when it becomes the primary. Therefore, this method will return null prior to being started and being elected primary.
public final IAepEngineStats getStats()
public final <T> T getApplicationState(int flowid)
This method returns the application state object associated with a
flow. It can only be invoked on a started engine. Given this state
constraint, the threading contraints and the how application state
is created/managed by the engine, this method should only
be invoked from the AepMessagingPrestartEvent
or the
AepMessagingStartedEvent
event handler. These are the only
point in the application lifecycle when the engine is considered
to be started, the message/event dispatch machinery is halted
and the state created implcitly by this method will not conflict
with state created implicitly by replication.
flowid
- The flow id.IllegalStateException
- Thrown if invoked after messaging
has been started.public final <T> T getApplicationState(MessageView message)
This method returns the application state object associated with the flow on which an inbound message was received.
message
- The inbound message.public final long getEngineTime()
This method is intended for use by applications using EventSourcing
that do time dependent message processing. This method provides the
current wall time (in millisecond resolution) as perceived by the
engine. If invoked from within a message processor handler and the HA
policy is set to EventSourcing
, this method returns the time stamped
on the message event (stamped just before the method is dispatched to
the application for processing). Since, for EventSourcing
applications,
the message is also replicated for parallel processing on the backup,
the backup will receive the same time when invoking this method thus
ensuring identical processing. If this method is called on an engine
operating in state replication mode or called from outside a message
processor, then this method will return the value returned by the
System.currentTimeMillis()
method.
public final long getEngineTimeMicros()
This method is intended for use by applications using EventSourcing
that do time dependent message processing. This method provides the
current wall time (in microseconds since the epoch) as perceived by the
engine. If invoked from within a message processor handler and the HA
policy is set to EventSourcing
, this method
returns the time stamped on the message event (stamped just before the method is
dispatched to the application for processing). Since, for
EventSourcing
applications,
the message is also replicated for parallel processing on the backup,
the backup will receive the same time when invoking this method thus
ensuring identical processing. If this method is called on an engine
operating in state replication mode or called from outside a message
processor, then this method will return the value returned by the
UtlTime.nowSinceEpoch()
method.
UtlTime.nowSinceEpoch()
public final void resumeCommit(AepTransactionStageEvent.ICommitContext context)
This method should be invoked by the application to resume a transaction commit suspended via the AepTransactionStageEvent. When the transaction needs to be resumed, the application should call this method supplying the transaction commit context present in the event used to suspend the transaction.
context
- The context of the suspended commit.public final void sendMessage(MessageChannel channel, IRogMessage message, Properties keyResolutionTable)
This method can only be invoked on a started engine.
NOTE: It is not safe for both message handlers and unsolicited sender threads to call this method, the only case where a thread that is not the dispatch thread may call this method is if the application is a purely sending application that will never send a message from a message or event handler.
channel
- The channel on which to send the message.message
- The message to send.keyResolutionTable
- The message's key resolution tablepublic final void sendMessage(MessageChannel channel, IRogMessage message, MessageChannel.RawKeyResolutionTable keyResolutionTable)
XString
key resolution table. This method is
the same sendMessage(MessageChannel, IRogMessage, Properties)
, but
performs key resolution using XString
logic that doesn't produce
garbage.
This method can only be invoked on a started engine.
AMessageChannel.RawKeyResolutionTable
instance can be obtained by calling
MessageBusBindingFactory.createRawKeyResolutionTable()
.channel
- The channel on which to send the message.message
- The message to send.keyResolutionTable
- The message's key resolution table.public final void sendMessage(MessageChannel channel, IRogMessage message, String key, Properties keyResolutionTable)
This method sets the key in the message and invokes the following:
sendMessage(MessageChannel, IRogMessage, Properties)
channel
- The channel on which to send the message.message
- The message to send.key
- The message key.keyResolutionTable
- The message's key resolution table
(ignored if the supplied key is non-null)public final void sendMessage(MessageChannel channel, IRogMessage message, XString key, MessageChannel.RawKeyResolutionTable keyResolutionTable)
sendMessage(MessageChannel, IRogMessage, String, Properties)
,
but uses a XString
to avoid creation of garbage.channel
- The channel on which to send the message.message
- The message to send.key
- The message key.keyResolutionTable
- The message's key resolution table
(ignored if the supplied key is non-null)public final void sendMessage(MessageChannel channel, IRogMessage message)
This method invokes sendMessage(MessageChannel, IRogMessage, Properties)
channel
- The channel on which to send the message.message
- The message to send.public final void replyToClient(MessageChannel channel, PktPacket request, PktPacket reply, int replyCount, int replyNum) throws Exception
This method is a convenience method to send a reply to a request packet received from an AEP application client. The reply sent by this method indicates successful request processing.
channel
- The client's messaging channel.request
- The request for which to the send the reply.reply
- The reply packet to send. A null value will
cause this method to create and send a generic reply packet.replyCount
- The number of replies for this request.replyNum
- The reply number.Exception
public final void replyToClientWithError(MessageChannel channel, PktPacket request, PktPacket reply, long errorCode) throws Exception
This method is a convenience method to send a reply to a request packet received from an AEP application client. The reply sent by this method indicates a failed request processing.
channel
- The client's messaging channel.request
- The request for which to the send the reply.reply
- The reply packet to send. A null value will cause this
method to create and send a generic reply packet.errorCode
- The error code.Exception
public final int createTransactionSavepoint()
A savepoint serves as a delimiting marker that can used to partially rollback changes within the
current transaction. A subsequent call to rollbackToTransactionSavepoint(int)
with the returned
savepoint will roll back state changes and outbound messages done subsequent to the savepoint.
The Restrictions outlined in rollbackToTransactionSavepoint(int)
apply to this method. If
any of the criteria listed in the those restrictions is not met, this method with throw an IllegalStateException
Usage of savepoints when operating with an AepEngine.HAPolicy
of EventSourcing is currently classified
as an expiremental feature.
IllegalStateException
- Thrown if the the engine is not in a state that supports
save point operations.rollbackToTransactionSavepoint(int)
public final int getTransactionSavepoint()
The method returns the current savepoint for a transaction in progress.
The Restrictions outlined in rollbackToTransactionSavepoint(int)
apply to this method. If
any of the criteria listed in the those restrictions is not met, this method with throw an IllegalStateException
IllegalStateException
- Thrown if the the engine is not in a state that supports
savepoint operations.rollbackToTransactionSavepoint(int)
public final void rollbackToTransactionSavepoint(int savepoint)
This method rolls back changes made to application state since the given savepoint. Additionally it rolls back any outbound messages sent as part of the transaction since the save point.
The rollback operation leaves the provided savepoint marker in place. For example,
if the application calls rollback with a savepoint value of 1, a subsequent
call to getTransactionSavepoint()
will return 1. Additional work done after
the rollback can thus be rolled back to the same point.
Any savepoints after the provided savepoint are discarded. If rollback is called with
a savepoint value of 1 when getTransactionSavepoint()
is at 2, savepoint 2 is
discarded.
Note that rolling back to the initial savepoint (0) does not rollback the entire transaction. Instead, the processed message remains in the transaction stream as a successfully event with no effects.
AepEngineDescriptor#getEnableTransactionSavepoints()
== true
getStore()
!= null
as the AepEngine relies on the store's transaction machinery to perform rollback.
This restriction may be relaxed in a future release.
isDispatchThread()
&& #
AepEngineDescriptor.getReplicateInParallel()
== false
IllegalStateException
is thrown. In addition to the
above restrictions an application must not use the following savepoint operations in the underlying
store:
IStoreBinding.createSavepoint()
IStoreBinding.rollback(int)
IStoreBinding.rollback()
IStoreBinding.getLastSavepoint()
createTransactionSavepoint()
at the beginning of
message processing to avoid rolling back work done by another handler.
Usage of savepoints when operating with an AepEngine.HAPolicy
of EventSourcing is currently classified
as an expiremental feature. Because application state is not managed by the platform for EventSourcing,
only an applications outbound messages are rolled back by this method.
When using EventSourcing, message handlers are invoked on a Backup instance or an instance recovering
from a transaction log. It is crucial that a backup or recovering instance's behavior or it will
lead to divergence in the application's outbound messages. This means that application logic on
a backup must create the same savepoints as a primary and rollback based on the same criteria.
For this reason it is often preferable for an EventSourcing app that encounters an error to simply
throw an exception from its event handler and let the inbound message's fate be governed by the
AepEngine.AppExceptionHandlingPolicy
.
EAepRollbackError
thrown from this method indicates that therd was an internal or runtime
error performing the rollback. In this case, application event handlers must allow the error
to be thrown back for the platform to handle as the application state may be in a corrupt state.
If the AepEngine can recover by rolling back the entire transaction, the error will be handled
according to the AepEngine.AppExceptionHandlingPolicy
, otherwise the engine will stop with the
EAepRollbackError.
savepoint
- The savepoint to roll back to.IllegalStateException
- Thrown if the the engine is not in a state that supports
savepoint operations.IllegalArgumentException
- if the savepoint is greater than the
current savepoint or less than 0.EAepRollbackError
- if the rollback failed - an application should not trap this exception.createTransactionSavepoint()
public final void setAsLastTransaction(Exception cause, boolean ignoreIfStarting, boolean shutdownCluster)
The method (1) marks the current transaction as the last transaction and (2)
marks the message from whose handler the method is being invoked as the last
message in the transaction. Once the current transaction is marked as the last
transaction, all subsequent inbound messages are ignored (but ensured that they
are not acknowledged). Once the last transaction is complete, the engine will
shutdown (stop(Exception)
) using same cause object supplied to this
method.
This method can only be invoked from within a message handler.
This method has no effect on backup agents unless lastClusterTransaction is set in which case backup agents shutdown too.
cause
- The cause of why last transaction is being triggered.
A value of null indicates 'normal' shutdownignoreIfStarting
- Normally, this method would throw an illegal state
exception if invoked while the engine is starting. However, there are cases
where special messages may be used to trigger a graceful shutdown. Since
those messages may be logged and can be replayed during initialization with
event sourcing, the same behavior may not be desirable during engine
initialization. With this flag set, the engine will just return from this
method if the engine is starting rather than throw an exception.shutdownCluster
- This parameter indicates whether the current
transaction should be treated as the last transaction for not only the
running agent but for the entire cluster. When operating in Event Sourcing
configuration, a value of true for this parameter will cause this method
call to be processed on all members of the cluster (note that, with Event
Sourcing, all cluster members process inbound messages). A value of false,
on the other hand, will cause this method invocation to be treated as a
no-op on backup members. Last cluster transaction functionality is not
currently supported for State Replication. A value of true specified in
this parameter with State Replication will cause an IllegalArgumentException
to be thrown.IllegalArgumentException
- Thrown if a value of true is specified on
an engine operating in the StateReplication HA mode.IllegalStateException
- Thrown if this method is invoked on an engine
in any state other than the started state (unless the ignoreIfStarting flag
is specified and in starting state) or if invoked from outside of a message
handler.public final void setAsLastTransaction(Exception cause, boolean ignoreIfStarting)
This method invoked setAsLastTransaction(cause, ignoreIfStarting, false)
public final void stop(Exception cause)
This method stops an AEP engine. It first flags the engine as 'stopping' to prevent messages/events beyond the current one from being processed. It then schedules a 'stop' event inline with its inbound event/message stream to stop the engine. If the method is called by the thread actively dispatching the current engine event, then the call immediately returns. Otherwise, the call will block and wait for the stop event to be processed. Note that this implies that for stops performed by the engine dispatching thread, the caller cannot assume that the engine has been stopped upon return from the method. However, this can be assumed if this method is invoked by a thread different from he current dispatching thread.
cause
- The reason why the engine is being stopped. A null value
indicates a 'normal' stop. A 'normal' stop results in the engine
'leaving' all joined channels. An 'abnormal' stop will not explicitly
'leave' its joined channels. When used with transports that support
durable subscription, this means that a 'normal' stop will remove the
durable subscriptions while an 'abnormal' stop will leave the durable
subscriptions intact. To preserve joined channels on a 'normal' stop,
an event handler for AepEngineStoppingEvent
can change the value of
AepEngineStoppingEvent.setPreserveChannelJoins(boolean)
.public final void stop()
This method invokes stop(null)
public final String getName()
IEventSource.getName()
getName
in interface IEventSource
public final void onEvent(Event event)
IEventHandler.onEvent(com.neeve.event.Event)
This method is the engine multiplexer's event handler, it should never be invoked directly by the application.
onEvent
in interface IEventHandler
event
- The event to be handled.public final void onEvent(IStoreEvent event)
IStoreEventHandler.onEvent(com.neeve.ods.IStoreEvent)
This method is the store event handler and should never be invoked directly by the application.
onEvent
in interface IStoreEventHandler
event
- The event to be handled.public <K,T extends IStoreObject> IStoreUniqueIndex<K,T> createStoreUniqueIndex(String fieldPath, String name)
IStoreBinding.createUniqueIndex(String, String)
after validating the operation.
Index can only be created under following conditions:
getState()
== Init
).
When running in a Talon XVM, an index can be created when the AepEngine is injected via a @AppInjectionPoint
annoted method.getHAPolicy()
== AepEngine.HAPolicy.StateReplication
Returned index instance can only be used from within engine's message handling thread
(i.e. isDispatchThread()
== true
), and until index is dropped.
Invoking index reference's methods outside of these conditions will throw IllegalStateException
NOTE: Store indexing is experimental feature that is still in incubation. This API may be changed and/or removed in a subsequent release. It is not recommended that this API be used in production without first consulting with Neeve Support. Store indexing API is not guaranteed to be garbage-free in this release.
fieldPath
- Field path of the field on which index is created.name
- Index name.IStoreUniqueIndex
instance if index created, else null
IllegalStateException
- if invalid state encountered - such as app configured with policy other than
AepEngine.HAPolicy.StateReplication
, or the store is not queryable, or index is not non-uniquefor more information.
public <K,T extends IStoreObject> IStoreNonUniqueIndex<K,T> createStoreNonUniqueIndex(String fieldPath, String name)
IStoreBinding.createNonUniqueIndex(String, String)
after validating the operation.
Index can only be created under following conditions:
getState()
== Init
).
When running in a Talon XVM, an index can be created when the AepEngine is injected via a @AppInjectionPoint
annoted method.getHAPolicy()
== AepEngine.HAPolicy.StateReplication
Returned index instance can only be used from within engine's message handling thread
(i.e. isDispatchThread()
== true
), and until index is dropped.
Invoking index reference's methods outside of these conditions will throw IllegalStateException
NOTE: Store indexing is experimental feature that is still in incubation. This API may be changed and/or removed in a subsequent release. It is not recommended that this API be used in production without first consulting with Neeve Support. Store indexing API is not guaranteed to be garbage-free in this release.
fieldPath
- Field path of the field on which index is created.name
- Index name.true
if index created, else false
IllegalStateException
- if invalid state encountered - such as app configured with policy other than
AepEngine.HAPolicy.StateReplication
, or the store is not queryable, or index is not non-uniquefor more information.
public <K,T extends IStoreObject> IStoreUniqueIndex<K,T> getStoreUniqueIndex(String fieldPath)
IStoreBinding.getUniqueIndex(String)
after validating the operation.
Returned index instance can only be used from within engine's message handling thread
(i.e. isDispatchThread()
== true
), and until index is dropped.
Invoking index reference's methods outside of these conditions will throw IllegalStateException
NOTE: Store indexing is experimental feature that is still in incubation. This API may be changed and/or removed in a subsequent release. It is not recommended that this API be used in production without first consulting with Neeve Support. Store indexing API is not guaranteed to be garbage-free in this release.
fieldPath
- Field path of the field on which index is created.IStoreUniqueIndex
instance for the index.IllegalStateException
- if invalid state encountered - such as app configured with policy other than
AepEngine.HAPolicy.StateReplication
, or the store is not queryable, or index is not non-uniqueIStoreUniqueIndex
public <K,T extends IStoreObject> IStoreNonUniqueIndex<K,T> getStoreNonUniqueIndex(String fieldPath)
IStoreBinding.getNonUniqueIndex(String)
after validating the operation.
Returned index instance can only be used from within engine's message handling thread
(i.e. isDispatchThread()
== true
), and until index is dropped.
Invoking index reference's methods outside of these conditions will throw IllegalStateException
NOTE: Store indexing is experimental feature that is still in incubation. This API may be changed and/or removed in a subsequent release. It is not recommended that this API be used in production without first consulting with Neeve Support. Store indexing API is not guaranteed to be garbage-free in this release.
fieldPath
- Field path of the field on which index is created.IStoreNonUniqueIndex
instance for the index.IllegalStateException
- if invalid state encountered - such as app configured with policy other than
AepEngine.HAPolicy.StateReplication
, or the store is not queryable, or index is not non-unique.IStoreNonUniqueIndex
public boolean dropStoreIndex(String fieldPath)
IStoreBinding.dropIndex(IStoreIndex)
after validating the operation.
This method can only be invoked from engine's message handling thread
(i.e. isDispatchThread()
== true
).
Invoking index reference's methods outside of these conditions will throw IllegalStateException
NOTE: Store indexing is experimental feature that is still in incubation. This API may be changed and/or removed in a subsequent release. It is not recommended that this API be used in production without first consulting with Neeve Support. Store indexing API is not guaranteed to be garbage-free in this release.
fieldPath
- Field path of the field on which the index was created.true
if index dropped, else false
if index not found.IllegalStateException
- if invalid state encountered - such as app configured with policy other than
AepEngine.HAPolicy.StateReplication
, or the store is not queryable.public boolean dropStoreIndex(IStoreIndex<?,? extends IStoreObject> indexView)
IStoreBinding.dropIndex(IStoreIndex)
after validating the operation.
This method can only be invoked from engine's message handling thread
(i.e. isDispatchThread()
== true
).
Invoking index reference's methods outside of these conditions will throw IllegalStateException
NOTE: Store indexing is experimental feature that is still in incubation. This API may be changed and/or removed in a subsequent release. It is not recommended that this API be used in production without first consulting with Neeve Support. Store indexing API is not guaranteed to be garbage-free in this release.
indexView
- View for the index to be droppedtrue
if index dropped, else false
if index not found.IllegalStateException
- if invalid state encountered - such as app configured with policy other than
AepEngine.HAPolicy.StateReplication
, or the store is not queryable.public boolean dropStoreIndexByName(String name)
IStoreBinding.dropIndexByName(String)
after validating the operation.
This method can only be invoked from engine's message handling thread
(i.e. isDispatchThread()
== true
).
Invoking index reference's methods outside of these conditions will throw IllegalStateException
NOTE: Store indexing is experimental feature that is still in incubation. This API may be changed and/or removed in a subsequent release. It is not recommended that this API be used in production without first consulting with Neeve Support. Store indexing API is not guaranteed to be garbage-free in this release.
name
- Index name.true
if index dropped, else false
if index not found.IllegalStateException
- if invalid state encountered.for more details
Copyright © 2019 Neeve Research, LLC. All Rights Reserved.