Package app.l2nx.gs.adapter.core.kafka
Class DefaultKafkaFactory
java.lang.Object
app.l2nx.gs.adapter.core.kafka.DefaultKafkaFactory
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
-
Constructor Details
-
DefaultKafkaFactory
public DefaultKafkaFactory()
-
-
Method Details
-
build
public app.l2nx.gs.kafka.KafkaState build(String brokers, String clientId, Map<String, Object> properties, Map<String, byte[]> staticHeaders, Consumer<app.l2nx.gs.kafka.KafkaState> stateChangeListener) Description copied from interface:KafkaFactoryCreate or replace theNxKafkasingleton with this configuration.Implementations MUST shut down any existing live
NxKafkainstance before re-init, so aDEGRADED → ACTIVEreconnect cycle that re-fetches Kafka credentials remains idempotent.Implementations MUST NOT block on broker reachability — return immediately with
KafkaState.DISCONNECTEDif the cluster is unreachable.nx-gs-kafkakeeps a background reconnect loop that will recover.- Specified by:
buildin interfaceKafkaFactory- Parameters:
brokers- comma-separated bootstrap serversclientId- client identifier — typicallynx-gs-adapter-<tenant-slug>-<server-slug>properties- raw Kafka client properties (security.protocol, sasl.mechanism, sasl.jaas.config)staticHeaders- Kafka headers stamped on every produced record (e.g.Nx-Server-Idresolved from the connect response); may be emptystateChangeListener- invoked on everyKafkaStatetransition after build (CONNECTED ↔ DISCONNECTED, → CLOSED)- Returns:
- the post-build state —
KafkaState.CONNECTEDorKafkaState.DISCONNECTED
-