Sequence declaration reference
Sequencing is declared in a YAML descriptor, by default loaded from
classpath:/messaging/jeap-sequential-inbox.yml (override with
jeap.messaging.sequential-inbox.config-location). The file has two top-level keys: an optional
subTypeResolvers map and a list of sequences.
Data model
Sequence
The optional sequencingStartTimestamp is an ISO local date-time, e.g.
sequencingStartTimestamp: '2026-10-01T08:00:00'. Before this timestamp the sequence records
messages without enforcing release conditions. Other sequences remain active unless the global
jeap.messaging.sequential-inbox.sequencing-start-timestamp also enables recording. Either future
timestamp enables recording; an elapsed sequence timestamp does not override the global switch.
At or after both timestamps, normal sequencing applies. All service instances must use the same
timezone and configuration. See recording rollout.
| Attribute | Cardinality | Description | Example |
|---|---|---|---|
name | Required | Name of the sequence (used in logs, the REST API and the sequence instance rows) | OrderSequence |
retentionPeriod | Required | How long a sequence instance is retained, as a Duration; drives expiry and housekeeping | 24h |
messages | Required | The list of SequencedMessageType entries that belong to the sequence |
SequencedMessageType
| Attribute | Cardinality | Description | Example |
|---|---|---|---|
type | Required | The jEAP message type name (the Avro message simple class name) | JmeOrderCreatedEvent |
subType | Optional | Subtype for fine-grained sequencing of a generic message type. Resolved by a SubTypeResolver; must be a value of the resolver's Java Enum | STOCK_AVAILABLE |
topic | Optional | Topic to consume the message from, if different from the default | my-topic |
topics | Optional | List of topics to consume the message from, see Consuming a message type from several topics. Mutually exclusive with topic | [my-topic, my-topic-v2] |
clusterName | Optional | Kafka cluster of the topic(s), if different from the default cluster | aws |
contextIdExtractor | Required | Fully-qualified class name implementing ContextIdExtractor; returns the contextId grouping messages into one instance (null = not sequenceable) | ch.admin.bit.example.OrderIdExtractor |
messageFilter | Optional | Fully-qualified class name implementing MessageFilter; shouldSequence returning false means the message bypasses the inbox and is handled immediately | ch.admin.bit.example.OrderCreatedEventFilter |
releaseCondition | Optional | The predecessor(s) that must be processed before this message is released. No condition means the message can be released as soon as it arrives |
Consuming a message type from several topics
By default a message type is consumed from exactly one topic: topic, or the message type's default
topic if topic is not declared. During a topic migration (e.g. from my-topic to my-topic-v2) a
consumer has to read the same message type from the old and the new topic for a while. Declare
the topics with topics instead of topic:
sequences:
- name: OrderSequence
retentionPeriod: 24h
messages:
- type: JmeOrderCreatedEvent
topics:
- my-topic
- my-topic-v2
contextIdExtractor: ch.admin.bit.example.OrderIdExtractor
The inbox starts one Kafka consumer per declared topic, all of them on the same cluster
(clusterName) and all of them feeding the same sequence. The topic a message was received from is
irrelevant for sequencing: release conditions, the contextId grouping and the message handler are
the same regardless of the topic. The topic is however recorded per message and used when a buffered
message is deserialized later or forwarded to the error handling service.
Each declared topic adds a listener container with the configured concurrency, so a second topic
doubles the number of consumer threads of that message type — and with it the number of database
connections the inbox may hold concurrently (the inbox holds a connection while a listener runs, see
Sequential Inbox idempotence). Re-check the Hikari pool size and
max.poll.interval.ms (see Configuration reference) before enabling a second
topic.
Rules validated on startup:
topicandtopicsare mutually exclusive on the same message, and topic names must not be empty- a topic must not be declared twice for the same message
- all entries of the same message type (i.e. all its subtypes) must declare the same topics
- a topic can be consumed for one message type only
Both topics need a consumer contract, as every topic is validated against the contracts of the consuming application:
@JeapMessageConsumerContract(value = JmeOrderCreatedEvent.TypeRef.class,
topic = {"my-topic", "my-topic-v2"})
A message that is delivered on both topics — for instance because messages have been copied to the new topic — is processed only once: the inbox de-duplicates on message type and idempotence id, independently of the topic (see Sequential Inbox idempotence).
Once the migration is finished, remove the old topic from topics (or replace topics with a
single topic). Messages that are still buffered are not affected, as they are replayed from the
database and not from Kafka.
ContextIdExtractor
A ContextIdExtractor is required for every message type in the sequence declaration. It extracts
the contextId from an incoming message — all messages with the same contextId are grouped into
one sequence instance (e.g. all messages for the same order). Returning null means the message
cannot be sequenced and is handled immediately.
Implement ContextIdExtractor<YourMessageType> and reference the fully-qualified class name in
contextIdExtractor:
public class ProcessIdExtractor implements ContextIdExtractor<AvroMessage> {
@Override
public String extractContextId(AvroMessage message) {
return message.getOptionalProcessId().orElse(null);
}
}
MessageFilter
A MessageFilter is optional. When configured, shouldSequence is called for each incoming
message: returning false means the message bypasses the inbox and is handled immediately — it
is not ignored, just not sequenced. Returning true (or having no filter) means the message follows
the normal sequencing path.
Implement MessageFilter<YourMessageType> and reference the fully-qualified class name in
messageFilter:
public class OrderCreatedEventFilter implements MessageFilter<JmeOrderCreatedEvent> {
@Override
public boolean shouldSequence(JmeOrderCreatedEvent message) {
return !"NOT_SEQUENCED".equals(message.getPayload().getOrderType());
}
}
Release conditions
A release condition references predecessors by their qualified name (type, or
type.subType when a subtype is used). Conditions can be nested with and and or.
# single predecessor
releaseCondition:
predecessor: JmeOrderCreatedEvent
# all of several predecessors
releaseCondition:
and:
- predecessor: JmeOrderValidatedEvent.STOCK_AVAILABLE
- predecessor: JmeOrderValidatedEvent.CUSTOMER_CREDIT_CHECKED
- predecessor: JmeOrderPreparedEvent
# any one of several predecessors
releaseCondition:
or:
- predecessor: JmeOrderShippedEvent
- predecessor: JmeOrderOtherEvent
SubTypeResolver
When one Avro message type represents several business events, a SubTypeResolver adds a subtype to
the message type name (<MessageType>.<SubType>), enabling fine-grained sequencing. The resolver
returns an Enum value — never null.
The following constraints are validated on startup:
- Must implement
SubTypeResolver<YourAvroMessage, YourSubtypeEnum> - All enum values must be declared as a
subTypein the sequence declaration - All
subTypevalues in the declaration must be valid enum values - A message type configured with a subtype cannot also be configured without a subtype
- Different subtypes of the same message type cannot have inconsistent topic configurations
Implement SubTypeResolver<YourMessageType, YourEnum> and register it in subTypeResolvers:
subTypeResolvers:
JmeOrderValidatedEvent: ch.admin.bit.example.OrderValidatedEventSubTypeResolver
public class OrderValidatedEventSubTypeResolver
implements SubTypeResolver<JmeOrderValidatedEvent, ValidationType> {
@Override
public ValidationType resolveSubType(JmeOrderValidatedEvent event) {
return event.getPayload().getValidationType();
}
}
Full example
subTypeResolvers:
JmeOrderValidatedEvent: ch.admin.bit.example.OrderValidatedEventSubTypeResolver
sequences:
- name: OrderSequence
retentionPeriod: 24h
messages:
- type: JmeOrderCreatedEvent
contextIdExtractor: ch.admin.bit.example.OrderIdExtractor
messageFilter: ch.admin.bit.example.OrderCreatedEventFilter
topic: my-custom-topic # optional: override default topic
clusterName: my-custom-cluster # optional: override default cluster
- type: JmeOrderValidatedEvent
subType: STOCK_AVAILABLE
contextIdExtractor: ch.admin.bit.example.OrderIdExtractor
releaseCondition:
predecessor: JmeOrderCreatedEvent
- type: JmeOrderValidatedEvent
subType: CUSTOMER_CREDIT_CHECKED
contextIdExtractor: ch.admin.bit.example.OrderIdExtractor
releaseCondition:
predecessor: JmeOrderCreatedEvent
- type: JmeOrderPreparedEvent
contextIdExtractor: ch.admin.bit.example.OrderIdExtractor
releaseCondition:
predecessor: JmeOrderCreatedEvent
- type: JmeOrderShippedEvent
contextIdExtractor: ch.admin.bit.example.OrderIdExtractor
releaseCondition:
and: # all predecessors must be processed
- predecessor: JmeOrderValidatedEvent.STOCK_AVAILABLE
- predecessor: JmeOrderValidatedEvent.CUSTOMER_CREDIT_CHECKED
- predecessor: JmeOrderPreparedEvent
- type: JmeOrderCustomEvent
contextIdExtractor: ch.admin.bit.example.OrderIdExtractor
releaseCondition:
or: # any one predecessor is sufficient
- predecessor: JmeOrderShippedEvent
- predecessor: JmeOrderOtherEvent