Class DefaultKafkaFactory

java.lang.Object
app.l2nx.gs.adapter.core.kafka.DefaultKafkaFactory
All Implemented Interfaces:
KafkaFactory

public final class DefaultKafkaFactory extends Object implements KafkaFactory
Default KafkaFactory that bridges to NxKafka.configure().build().

Shuts down any live singleton before init so a reconnect cycle that re-fetches Kafka credentials produces a fresh client.

  • Constructor Details

    • DefaultKafkaFactory

      public DefaultKafkaFactory()
  • Method Details

    • build

      public app.l2nx.gs.kafka.KafkaState build(String brokers, String clientId, Map<String,Object> properties, Consumer<app.l2nx.gs.kafka.KafkaState> stateChangeListener)
      Description copied from interface: KafkaFactory
      Create or replace the NxKafka singleton with this configuration.

      Implementations MUST shut down any existing live NxKafka instance before re-init, so a DEGRADED → ACTIVE reconnect cycle that re-fetches Kafka credentials remains idempotent.

      Implementations MUST NOT block on broker reachability — return immediately with KafkaState.DISCONNECTED if the cluster is unreachable. nx-gs-kafka keeps a background reconnect loop that will recover.

      Specified by:
      build in interface KafkaFactory
      Parameters:
      brokers - comma-separated bootstrap servers
      clientId - client identifier — typically nx-gs-adapter-<tenant-slug>-<server-slug>
      properties - raw Kafka client properties (security.protocol, sasl.mechanism, sasl.jaas.config)
      stateChangeListener - invoked on every KafkaState transition after build (CONNECTED ↔ DISCONNECTED, → CLOSED)
      Returns:
      the post-build state — KafkaState.CONNECTED or KafkaState.DISCONNECTED