CommandDispatcher

abstract class CommandDispatcher(val id: String, val version: String, commands: List<Command>, logger: Logger, logCategory: String = id, scheduler: Scheduler) : Dispatcher

Abstract Dispatcher that routes each Dispatch through a CommandRegistry.

Subclasses provide the list of Commands at construction time. Command names are extracted from the dispatch payload via the Dispatch.getCommands extension.

The scheduler controls which thread the per-dispatch completion callback is invoked on once all of the dispatch's commands have finished. Runtime subclasses must supply the regular Tealium scheduler (i.e. schedulers.tealium) so that completion always lands on that dedicated thread. Passing Scheduler.SYNCHRONOUS here is intended for tests only: it makes completion run in whichever command-execution thread happens to finish last, which is not safe for runtime use.

Constructors

Link copied to clipboard
constructor(id: String, version: String, commands: List<Command>, logger: Logger, logCategory: String = id, scheduler: Scheduler)

Properties

Link copied to clipboard
open override val dispatchLimit: Int

Sets the maximum number of Dispatches that can safely be processed by the dispatch implementation. Default is 1

Link copied to clipboard
override val id: String

The unique id identifying this Module

Link copied to clipboard
override val version: String

A string describing the version of this Module.

Functions

Link copied to clipboard
override fun dispatch(dispatches: List<Dispatch>, callback: Callback<List<Dispatch>>): Disposable

Locked routing bridge: for each dispatch, executes its commands in parallel. Invokes callback once per Dispatch as it completes, consistent with the Dispatcher contract for split-batch acknowledgement.

Link copied to clipboard
open fun onShutdown()

Called when this Module has been determined to be shutdown. This could happen for the following reasons:

Link copied to clipboard
open fun updateConfiguration(configuration: DataObject): Module?

Called whenever updated configuration has been made available for this specific Module.