Skip to content

Extending uGroup

Qichao Chu edited this page Apr 9, 2026 · 1 revision

Extending uGroup

uGroup uses interfaces to allow custom implementations. Define a Spring @Bean to override any default.

MetricsProvider

Why override:

  • Integrate with your existing metrics system (Datadog, StatsD, CloudWatch, etc.)
  • Add custom tags (environment, team, service) to all metrics
  • Route metrics to multiple backends simultaneously
@Bean
public MetricsProvider metricsProvider() {
    return new DatadogMetricsProvider(datadogClient);
}

ClusterConfig

Why override:

  • Dynamic cluster discovery from service registry (Consul, ZooKeeper, etc.)
  • Multi-cluster support with automatic failover
  • Load Kafka credentials from secrets manager (Vault, AWS Secrets Manager)
  • Environment-specific configuration (dev/staging/prod)
@Bean
public ClusterConfig clusterConfig() {
    return new ConsulClusterDiscovery(consulClient);
}

WatchListProvider

Why override:

  • Load consumer groups from a database or API
  • Integrate with your deployment system to auto-discover consumers
  • Filter based on custom metadata (team ownership, SLA tier, etc.)
  • Sync with a configuration management system
@Bean
public List<WatchListProvider> watchListProviders() {
    return List.of(
        new DatabaseWatchListProvider(dataSource),  // From your metadata DB
        new KubernetesWatchListProvider(k8sClient)  // Auto-discover from K8s
    );
}

OffsetCache

Why override:

  • Distributed caching with Redis/Memcached for multi-instance deployments
  • Persistent cache that survives restarts
  • Share offset state across uGroup instances for HA setups
@Bean
public OffsetCache offsetCache() {
    return new RedisOffsetCache(redisClient);
}

OffsetFetcher

Why override:

  • Add caching layer for Kafka API calls
  • Implement retry logic or circuit breakers
  • Use a different Kafka client library
@Bean
public OffsetFetcher offsetFetcher() {
    return new CachedOffsetFetcher(new DirectOffsetFetcher(clusterConfig));
}

Clone this wiki locally