Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datahub project Datahub RestEmitterEmitMode

From Leeroopedia


Knowledge Sources
Domains Java_SDK, Metadata_Emission, Client_Configuration
Last Updated 2026-02-10 00:00 GMT

Overview

An enum that controls the consistency versus performance tradeoff for metadata change persistence and indexing in the DataHub V2 Java SDK.

Description

EmitMode determines how metadata changes are persisted to primary storage (SQL) and indexed in search storage (Elasticsearch) when emitted through the DataHub SDK. It provides three levels of consistency:

Mode SQL Update Elasticsearch Update HTTP Implementation Best For
SYNC_WAIT Synchronous Synchronous async=false, X-DataHub-Sync-Index-Update: true Critical operations requiring immediate searchability
SYNC_PRIMARY (default) Synchronous Asynchronous async=false Balanced consistency and performance; default for SDK operations
ASYNC Asynchronous Asynchronous async=true High-throughput bulk ingestion pipelines

SYNC_WAIT provides the strongest consistency guarantee at the highest cost -- both the primary SQL database and the Elasticsearch index are updated before the call returns. Changes are immediately visible in both direct entity reads and search results.

SYNC_PRIMARY (the default) provides a balance -- the SQL database is updated synchronously so direct entity reads reflect the change immediately, but Elasticsearch indexing happens asynchronously, meaning search results may have a slight delay.

ASYNC provides the highest throughput by queuing the change for entirely asynchronous processing. The API returns immediately, and both SQL and Elasticsearch updates happen in the background. This is best for bulk ingestion where eventual consistency is acceptable.

Usage

Set the emit mode on DataHubClientConfigV2 to control the persistence behavior. Choose based on your consistency requirements versus throughput needs.

Code Reference

Source Location

metadata-integration/java/datahub-client/src/main/java/datahub/client/v2/config/EmitMode.java

Signature

public enum EmitMode {
    SYNC_WAIT,
    SYNC_PRIMARY,
    ASYNC
}

Import

import datahub.client.v2.config.EmitMode;

I/O Contract

Inputs

This is an enum with no constructor parameters. One of the three constants (SYNC_WAIT, SYNC_PRIMARY, ASYNC) is selected when configuring DataHubClientConfigV2.

Outputs

The selected EmitMode value is consumed by DataHubClientConfigV2.toRestEmitterConfig() to set:

  • The asyncIngest flag on RestEmitterConfig (true for ASYNC, false otherwise).
  • The X-DataHub-Sync-Index-Update HTTP header ("true" for SYNC_WAIT only).

Usage Examples

// Strongest consistency: wait for both SQL and Elasticsearch
DataHubClientConfigV2 config = DataHubClientConfigV2.builder()
    .server("http://localhost:8080")
    .emitMode(EmitMode.SYNC_WAIT)
    .build();

// Default balanced mode (SYNC_PRIMARY)
DataHubClientConfigV2 config = DataHubClientConfigV2.builder()
    .server("http://localhost:8080")
    .build();  // emitMode defaults to SYNC_PRIMARY

// Highest throughput for bulk ingestion
DataHubClientConfigV2 config = DataHubClientConfigV2.builder()
    .server("http://localhost:8080")
    .emitMode(EmitMode.ASYNC)
    .build();

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment