Skip to main content

Archived artifacts & events

When the PAS has archived a record it accumulates everything about the archiving operation (process data, metadata, object metadata) into an archived artifact and makes it available in two ways: an in-process listener interface and a published Kafka event.

The archived artifact​

An archived artifact exposes, among others:

FieldDescription
Process IdId of the process in which the data was created/changed/deleted
Reference IdId of the archived record (unique together with the version)
Reference Id TypeType stored in the catalog
VersionVersion of the record (may be empty if unversioned)
Payload / Content TypeThe archived data (binary) and its content type
System / Schema / Schema VersionThe archive type coordinates
Storage Object Bucket / Key / Version IdWhere the data was stored in S3 (version id assigned by the store)
Expiration DaysRetention period (see Data expiration & locking)
MetadataAdditional application-defined metadata

ArtifactArchivedListener​

Implement the ArtifactArchivedListener plugin interface (as a Spring bean) to receive each archived artifact — for example to record the S3 coordinates (bucket/key) in an archive catalog so archived records can be searched and retrieved later.

@Component
public class CatalogArtifactListener implements ArtifactArchivedListener {
@Override
public void onArtifactArchived(ArchivedArtifact archivedArtifact) {
// e.g. register the artifact in a catalog
}

@Override
public void archivedArtifactTypesDeclared(Set<ArchivedArtifactType> archivedArtifactTypes) {
// optional: e.g. verify that the catalog accepts the reference ID types of all archive types
}
}

Declared archive types​

archivedArtifactTypesDeclared lets a listener validate the types of the artifacts an instance will archive before it processes any message, for example the reference ID types against an external registry:

  • When: once at startup, after the archive types have been loaded and before the Kafka message consumers are started (they start on Spring Boot's ApplicationStartedEvent). This also holds with spring.main.lazy-initialization=true. Every ArtifactArchivedListener bean is invoked.
  • What: all archive types known to the instance, i.e. the Avro archive types registered by an ArchiveTypeProvider and the archive types defined in jeap.processarchive.registry.types. An ArchivedArtifactType consists of system, name, version and referenceIdType. Every ArchivedArtifact of an archive type carries its referenceIdType. Several archive types (e.g. the versions of an archive type) can share the same reference ID type.
  • Feature flags: the archive types are reported regardless of the publication feature flags of the message configurations. The archive type of an artifact is only determined when a message is processed (by the archive data provider, or by the remote data endpoint for uri configurations), so an archive type is not linked to a message configuration and its feature flag. Reporting all archive types ensures that a listener also verifies the types of artifacts which are only announced once a feature flag is activated.
  • Failure: if the method throws an exception, the startup of the instance is aborted, and the listeners following it are not invoked.

The method has a no-op default implementation, existing listeners are unaffected.

SharedArchivedArtifactVersionCreatedEvent​

For every archived artifact the PAS publishes a SharedArchivedArtifactVersionCreatedEvent, notifying consumers that a new artifact version exists in the archive. The event's variant is set to <System>_<DataSchemaType>, e.g. JME_DecreeDocument. The event definition lives in the jEAP Message Type Registry.

Configure the event topic and system identity, or disable publication, in Configuration.

Idempotence​

Each archived artifact gets an idempotence id, and the published event's idempotence id is that value with a -event suffix. The id is derived deterministically so retries are idempotent:

<messageType>_<sha256-hex over (messageIdempotenceId, system, schema, referenceId[, version])>

The message type prefix keeps the id attributable in logs; the SHA-256 hash (64 lowercase hex characters) covers the incoming message's idempotence id and a discriminator (system, schema, referenceId, and version when present) that makes the id unique per artifact, while keeping the id length fixed at the message type name plus 65 characters. Each field in the hash input is length-prefixed, so field boundaries are unambiguous and distinct field values cannot collide. This matters when one message produces multiple artifacts: the PAS requires the ids of all artifacts of a message to be distinct and fails fast otherwise.

Because delivery is at-least-once, a retried message re-archives its artifacts (a new S3 object version) and re-publishes their events; downstream consumers deduplicate by the event idempotence id.

Partial failures with multiple artifacts​

The PAS extracts the data for all matching configurations and checks for duplicate artifact idempotence IDs before storing any artifact. Schema validation, storage and listener notification then happen sequentially for each artifact. They do not form one atomic transaction across all artifacts.

If a later artifact or listener fails, earlier S3 writes and notifications are not rolled back. A retry can therefore store and announce those earlier artifacts again. Downstream listeners and event consumers must tolerate redelivery using the stable artifact or event idempotence ID.

Publication feature flag​

Publication of an archived artifact can be gated per message with a featureFlag in messages.json, which lets you deploy an archiving configuration without activating it yet:

{ "messageName": "JmeDecreeCreatedEvent", "topicName": "...", "featureFlag": "FEATURE_DECREE_CREATED" }

When the flag is inactive at processing time, the artifact is not announced to the listeners (and no event is published). Once the flag is activated, new artifacts are announced; artifacts processed while the flag was inactive are not announced retroactively.

Feature-flag state is configured with Togglz:

togglz:
features:
FEATURE_DECREE_CREATED:
enabled: true

The PAS also exposes the standard feature-flag metric, e.g. feature_flag{client="...",name="FEATURE_DECREE_CREATED"} 1.0.