Class CommandsBootstrap
java.lang.Object
app.l2nx.gs.adapter.core.commands.CommandsBootstrap
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 ClassesModifier and TypeClassDescriptionstatic final classTuple of theNxCommandsfaçade and the optionalCommandsConsumer. -
Method Summary
Modifier and TypeMethodDescriptionstatic CommandsBootstrap.Startedstart(@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, theNxCommandsfaçade, and (whenmessagingTopics.commandsTopicis configured) a Kafka consumer + daemon thread.static @Nullable CommandsConsumerswap(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 existingNxCommandsfaçade, preserving its registered handlers across reconnect.
-
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 existingNxCommandsfaçade, preserving its registered handlers across reconnect. Modules that capturedctx.commands()from an earlieronConnectkeep working with no re-registration.Caller MUST stop the previous
CommandsConsumerfirst — 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, theNxCommandsfaçade, and (whenmessagingTopics.commandsTopicis configured) a Kafka consumer + daemon thread. Returns aCommandsBootstrap.Startedbundle.- Parameters:
messagingTopics- the platform-issued addressing bundle; may benull(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-commandsfor the Kafkaclient.id(broker logs only).groupId- Kafkagroup.idfor the commands consumer. Lives under the per-tenant prefix (<tenant>.gs.commands.<server>) so theUser:<tenant>principal's group ACL (prefixed on<tenant>.) covers it.hostExecutor- host's game-sideExecutor; may benullwhen host code has not registered one — handlers requiringctx.host().sync(...)will then throwIllegalStateExceptionon first hop.events- theNxEventsfaçade so handlers can publish side-effect events.replySender- the bridge to the actual Kafka send (production wires this toNxKafka.sendBytesKeyRecord).config- operator-tunable knobs; falls back toCommandsConfig.defaults()whennull.
-