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.KafkaCredentials, java.lang.String, java.lang.String, java.util.UUID, java.util.concurrent.Executor, java.util.concurrent.Executor, app.l2nx.gs.adapter.api.spi.NxEvents, app.l2nx.gs.adapter.api.spi.NxSync, 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.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Tuple of the NxCommands façade and the optional CommandsConsumer.
  • Method Summary

    Modifier and Type
    Method
    Description
    start(@Nullable app.l2nx.gs.adapter.api.rest.MessagingTopics messagingTopics, app.l2nx.gs.adapter.api.rest.KafkaCredentials kafka, String clientIdBase, String groupId, UUID ownServerId, @Nullable Executor hostExecutor, Executor ioExecutor, app.l2nx.gs.adapter.api.spi.NxEvents events, app.l2nx.gs.adapter.api.spi.NxSync sync, 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.
    static @Nullable CommandsConsumer
    swap(app.l2nx.gs.adapter.api.spi.NxCommands facade, @Nullable app.l2nx.gs.adapter.api.rest.MessagingTopics messagingTopics, app.l2nx.gs.adapter.api.rest.KafkaCredentials kafka, String clientIdBase, String groupId, UUID ownServerId, @Nullable Executor hostExecutor, Executor ioExecutor, app.l2nx.gs.adapter.api.spi.NxEvents events, app.l2nx.gs.adapter.api.spi.NxSync sync, CommandsConsumer.ReplySender replySender, @Nullable CommandsConfig config)
    Rebuild the consumer in-place behind an existing NxCommands façade, preserving its registered handlers across reconnect.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • swap

      public static @Nullable CommandsConsumer swap(app.l2nx.gs.adapter.api.spi.NxCommands facade, @Nullable app.l2nx.gs.adapter.api.rest.MessagingTopics messagingTopics, app.l2nx.gs.adapter.api.rest.KafkaCredentials kafka, String clientIdBase, String groupId, UUID ownServerId, @Nullable Executor hostExecutor, Executor ioExecutor, app.l2nx.gs.adapter.api.spi.NxEvents events, app.l2nx.gs.adapter.api.spi.NxSync sync, CommandsConsumer.ReplySender replySender, @Nullable CommandsConfig config)
      Rebuild the consumer in-place behind an existing NxCommands façade, preserving its registered handlers across reconnect. Modules that captured ctx.commands() from an earlier onConnect keep working with no re-registration.

      Caller MUST stop the previous CommandsConsumer first — this method only creates the new one.

    • start

      public static CommandsBootstrap.Started start(@Nullable app.l2nx.gs.adapter.api.rest.MessagingTopics messagingTopics, app.l2nx.gs.adapter.api.rest.KafkaCredentials kafka, String clientIdBase, String groupId, UUID ownServerId, @Nullable Executor hostExecutor, Executor ioExecutor, app.l2nx.gs.adapter.api.spi.NxEvents events, app.l2nx.gs.adapter.api.spi.NxSync sync, 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 for the Kafka client.id (broker logs only).
      groupId - Kafka group.id for the commands consumer. Lives under the per-tenant prefix (<tenant>.gs.commands.<server>) so the User:<tenant> principal's group ACL (prefixed on <tenant>.) covers it.
      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.