Package org.opennms.core.ipc.sink.common
Class AbstractMessageDispatcherFactory<W>
- java.lang.Object
-
- org.opennms.core.ipc.sink.common.AbstractMessageDispatcherFactory<W>
-
- Type Parameters:
W
- type of module specific state or meta-data, useVoid
if none is used
- All Implemented Interfaces:
MessageDispatcherFactory
- Direct Known Subclasses:
AmazonSQSLocalMessageDispatcherFactory
,AmazonSQSRemoteMessageDispatcherFactory
,CamelLocalMessageDispatcherFactory
,CamelRemoteMessageDispatcherFactory
,GrpcLocalDispatcherFactory
,KafkaLocalMessageDispatcherFactory
,KafkaRemoteMessageDispatcherFactory
,MinionGrpcClient
,MockMessageDispatcherFactory
,OsgiLocalDispatcherFactory
public abstract class AbstractMessageDispatcherFactory<W> extends java.lang.Object implements MessageDispatcherFactory
This class does all the hard work of building and maintaining the state of the message dispatchers so that concrete implementations only need to focus on dispatching the messages. Different types of dispatchers are created based on whether or not the module is using aggregation. Asynchronous dispatchers use a queue and a thread pool to delegate to a suitable synchronous dispatcher.- Author:
- jwhite
-
-
Constructor Summary
Constructors Constructor Description AbstractMessageDispatcherFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <S extends Message,T extends Message>
AsyncDispatcher<S>createAsyncDispatcher(SinkModule<S,T> module)
Creates a new dispatcher used to send messages asynchronously.<S extends Message,T extends Message>
SyncDispatcher<S>createSyncDispatcher(SinkModule<S,T> module)
Creates a new synchronous dispatcher that will lock the calling thread when dispatching messages.protected <S extends Message,T extends Message>
SyncDispatcher<S>createSyncDispatcher(DispatcherState<W,S,T> state)
abstract <S extends Message,T extends Message>
voiddispatch(SinkModule<S,T> module, W metadata, T message)
abstract org.osgi.framework.BundleContext
getBundleContext()
abstract java.lang.String
getMetricDomain()
abstract com.codahale.metrics.MetricRegistry
getMetrics()
<S extends Message,T extends Message>
WgetModuleMetadata(SinkModule<S,T> module)
Optionally build meta-data or state information for the module which will be passed on all the calls todispatch(org.opennms.core.ipc.sink.api.SinkModule<S, T>, W, T)
.abstract io.opentracing.Tracer
getTracer()
void
onDestroy()
void
onInit()
-
-
-
Method Detail
-
dispatch
public abstract <S extends Message,T extends Message> void dispatch(SinkModule<S,T> module, W metadata, T message)
-
getMetricDomain
public abstract java.lang.String getMetricDomain()
-
getBundleContext
public abstract org.osgi.framework.BundleContext getBundleContext()
-
getTracer
public abstract io.opentracing.Tracer getTracer()
-
getMetrics
public abstract com.codahale.metrics.MetricRegistry getMetrics()
-
getModuleMetadata
public <S extends Message,T extends Message> W getModuleMetadata(SinkModule<S,T> module)
Optionally build meta-data or state information for the module which will be passed on all the calls todispatch(org.opennms.core.ipc.sink.api.SinkModule<S, T>, W, T)
. This is useful for calculating things like message headers which are re-used on every dispatch.- Parameters:
module
-- Returns:
-
createSyncDispatcher
public <S extends Message,T extends Message> SyncDispatcher<S> createSyncDispatcher(SinkModule<S,T> module)
Description copied from interface:MessageDispatcherFactory
Creates a new synchronous dispatcher that will lock the calling thread when dispatching messages.- Specified by:
createSyncDispatcher
in interfaceMessageDispatcherFactory
-
createAsyncDispatcher
public <S extends Message,T extends Message> AsyncDispatcher<S> createAsyncDispatcher(SinkModule<S,T> module)
Description copied from interface:MessageDispatcherFactory
Creates a new dispatcher used to send messages asynchronously. The behavior of the asynchronous dispatcher is defined by the module'sAsyncPolicy
.- Specified by:
createAsyncDispatcher
in interfaceMessageDispatcherFactory
-
createSyncDispatcher
protected <S extends Message,T extends Message> SyncDispatcher<S> createSyncDispatcher(DispatcherState<W,S,T> state)
-
onInit
public void onInit()
-
onDestroy
public void onDestroy()
-
-