Class CommandsBootstrap

java.lang.Object
app.l2nx.gs.adapter.core.commands.CommandsBootstrap

public final class CommandsBootstrap extends Object
Public factory for the commands consume subsystem. NxAdapter calls start(app.l2nx.gs.adapter.api.rest.MessagingTopics, app.l2nx.gs.adapter.api.rest.KafkaConfig, java.lang.String, java.util.concurrent.Executor, app.l2nx.gs.adapter.api.spi.NxEvents, app.l2nx.gs.adapter.core.commands.CommandsConsumer.ReplySender, app.l2nx.gs.adapter.core.commands.CommandsConfig) once per connect cycle to wire up the registry + Kafka consumer + daemon thread, returning a CommandsBootstrap.Started bundle carrying the CommandsConsumer (for shutdown + heartbeat) and the NxCommands façade (for ConnectContext.commands()).

Hides CommandTypeRegistry, NxCommandsImpl, CommandContextImpl, and HostExecutorImpl — those are package-private implementation details. Callers depend only on the public NxCommands interface and the CommandsConsumer class.

When MessagingTopics.getCommandsTopic() is unconfigured, this factory still produces an NxCommands façade (so host code's unconditional ctx.commands().on(...) calls succeed) but DOES NOT spawn a Kafka consumer thread. The CommandsConsumer returned in that case is null — the caller (i.e. NxAdapter) treats that as "commands disabled" for heartbeat purposes.

  • Method Details

    • start

      public static CommandsBootstrap.Started start(@Nullable app.l2nx.gs.adapter.api.rest.MessagingTopics messagingTopics, app.l2nx.gs.adapter.api.rest.KafkaConfig kafka, String clientIdBase, @Nullable Executor hostExecutor, app.l2nx.gs.adapter.api.spi.NxEvents events, CommandsConsumer.ReplySender replySender, @Nullable CommandsConfig config)
      Wire up the registry, the NxCommands façade, and (when messagingTopics.commandsTopic is configured) a Kafka consumer + daemon thread. Returns a CommandsBootstrap.Started bundle.
      Parameters:
      messagingTopics - the platform-issued addressing bundle; may be null (treated as commands disabled).
      kafka - platform-issued Kafka config; provides brokers, SASL credentials, etc.
      clientIdBase - base client id (e.g. nx-gs-adapter-<tenant>-<server>); the commands consumer appends -commands.
      hostExecutor - host's game-side Executor; may be null when host code has not registered one — handlers requiring ctx.host().sync(...) will then throw IllegalStateException on first hop.
      events - the NxEvents façade so handlers can publish side-effect events.
      replySender - the bridge to the actual Kafka send (production wires this to NxKafka.sendBytesKeyRecord).
      config - operator-tunable knobs; falls back to CommandsConfig.defaults() when null.