Skip to main content

Couchbase Audit Store

The Couchbase audit store (CouchbaseSyncAuditStore) enables Flamingock to record execution history and ensure safe coordination across distributed deployments using Couchbase as the storage backend.

For a conceptual explanation of the audit store vs target systems, see Audit store vs target system.

Version compatibility

ComponentVersion Requirement
Couchbase Java Client3.6.0+

Couchbase Java Client 3.6.0+ is required and must be included in your project dependencies.

Installation

Add the Couchbase Java Client dependency to your project:

implementation("com.couchbase.client:java-client:3.7.0")

Basic setup

Configure the audit store using a Couchbase Target System to get the connection configuration:

var auditStore = CouchbaseAuditStore.from(couchbaseTargetSystem);

A CouchbaseAuditStore must be created from an existing CouchbaseTargetSystem.

This ensures that both components point to the same external Couchbase bucket:

  • The Target System applies your business changes.
  • The Audit Store stores the execution history associated with those changes.

Internally, the Audit Store takes the Target System’s connection settings (cluster + bucket name) and creates its own dedicated access handle, keeping audit operations isolated while still referring to the same physical system.

For a full conceptual explanation of this relationship, see Target Systems vs Audit Store.

Optional configurations can be added via .withXXX() methods.

Register Audit Store

Once created, you need to register this audit store with Flamingock. See Registering the community audit store for details.

Optional configuration (.withXXX() methods)

These configurations can be customized via .withXXX() methods with no global context fallback:

ConfigurationMethodDefaultDescription
Auto Create.withAutoCreate(enabled)trueAuto-create collections and indexes
Scope Name.withScopeName(name)_defaultScope where audit collections will be created
Audit Repository Name.withAuditRepositoryName(name)flamingockAuditLogCollection name for audit entries
Lock Repository Name.withLockRepositoryName(name)flamingockLockCollection name for distributed locks

⚠️ Warning: Ensure your Couchbase user has permissions to create collections if autoCreate is enabled.

Configuration example

Here's a comprehensive example showing the configuration:

// Create a Couchbase Target System
CouchbaseTargetSystem couchbaseTargetSystem = new CouchbaseTargetSystem("couchbase", cluster, "bucketName");
// Audit store configuration (mandatory via constructor)
var auditStore = CouchbaseSyncAuditStore.from(couchbaseTargetSystem)
.withScopeName("custom-scope") // Optional configuration
.withAutoCreate(true); // Optional configuration

// Register with Flamingock
Flamingock.builder()
.setAuditStore(auditStore)
.addTargetSystems(targetSystems...)
.build();

Audit store configuration resolution:

  • CouchbaseTargetSystem: Must be provided via from() method. Gets Cluster and BucketName from the target system.
  • Scope settings: Uses explicit configuration via properties

This architecture ensures explicit audit store configuration with no fallback dependencies.

Next steps