Upgrade to 2.0.0
Upgrade from 1.11.1 using your existing database. Tables, payloads, handler IDs and retry state stay in place; pending records can be processed after the upgrade.
1. Update dependencies
Set io.namastack:namastack-outbox-bom to 2.0.0 and remove explicit 1.x versions
from individual Namastack modules. JDBC and MongoDB starter names are unchanged.
Replace these removed modules if you use them:
| Remove | Use instead |
|---|---|
namastack-outbox-starter-jpa | namastack-outbox-starter-jdbc |
namastack-outbox-jpa | namastack-outbox-jdbc |
namastack-outbox-metrics / namastack-outbox-tracing | namastack-outbox-observability |
JPA applications: keep your business entities, Spring Data JPA and
JpaTransactionManager. JDBC outbox persistence must use the same DataSource.
Point JDBC at your existing physical table names if Hibernate used custom naming;
see persistence configuration.
Remove explicit references to the old Namastack JPA entities and dialect.
2. Update configuration
Rename deprecated properties
All paths below are relative to namastack.outbox. Skip these renames if you already
use the replacement names.
| Old property | Replacement |
|---|---|
poll-interval | polling.fixed.interval |
batch-size | polling.batch-size |
rebalance-interval | instance.rebalance-interval |
processing.publish-after-save | multicaster.publish-after-save |
processing.shutdown-timeout-seconds | processing.shutdown-timeout |
instance.heartbeat-interval-seconds | instance.heartbeat-interval |
instance.stale-instance-timeout-seconds | instance.stale-instance-timeout |
instance.graceful-shutdown-timeout-seconds | instance.graceful-shutdown-timeout |
Convert values from *-seconds to durations: 30 becomes 30s. Carry over the
old property's effective value and update all configuration sources, including
environment variables. Removed properties can be silently ignored.
Restore completed-record metrics
In 2.0.0, namastack.outbox.observability.metrics.record-statuses defaults to
[NEW, FAILED]. Completed-record counts are no longer enabled by default:
the outbox.records gauge with outbox.record.status=completed is not registered.
Dashboards and alerts that use this series will see a missing metric, not a zero count.
To keep collecting completed-record counts, explicitly include COMPLETED:
namastack:
outbox:
observability:
metrics:
record-statuses: [NEW, FAILED, COMPLETED]
Counting completed records adds database work that grows with retained history. If you do not need that count, keep the default and update affected dashboards and alerts. Update legacy meter names and tags using the current metric list.
Restore active observation timers with Spring Boot 4.2
When upgrading Spring Boot from 4.1 to 4.2, observation-based *.active long-task
timers are no longer created by default. This affects dashboards and alerts that
measure in-progress outbox scheduling, delivery attempts or handler invocations.
Timers for completed operations continue to be recorded.
If you use these active-operation metrics, enable them explicitly:
management:
metrics:
observations:
include-active-long-task-timer: true
Remove management.metrics.observations.ignored-meters if configured; Spring Boot
4.2 removes that property. The new setting applies to all observations handled by
Boot's auto-configured DefaultMeterObservationHandler.
See the Spring Boot migration notes.
3. Add the new database indexes
MongoDB: no collection or index migration is required. Continue with Deploy and verify.
JDBC and JPA → JDBC: apply the SQL below for your database in a new Flyway migration or Liquibase changeset. Keep previously applied migrations and existing tables unchanged.
The table and column layout stays the same. The new indexes support the revised polling, record-loading and metrics queries. Existing records remain readable with the old indexes, but that does not establish their performance under your workload. Install the new indexes as part of the upgrade.
Add a new migration
Choose the tab for your database and copy its SQL into the next unused migration
version, for example V42__add_outbox_2_indexes.sql, or a new Liquibase SQL
changeset. Keep the original table-creation migration unchanged. Apply the new
migration before starting 2.0.0 workers.
These scripts assume the default outbox_record table and that the new index names
do not exist yet. If schema initialization has already created an index, compare
its definition with the SQL below and omit that creation statement when it matches.
If an earlier attempt partially succeeded, reconcile those indexes before retrying.
For custom schemas, table prefixes or table names, use the existing physical table name throughout. Qualify names for the target schema; when several outboxes share a schema, also give each outbox's indexes distinct names.
Each tab links to the complete table and index definitions on main for reference.
- PostgreSQL
- MySQL / MariaDB
- H2
- SQL Server
- Oracle
CREATE INDEX idx_outbox_record_status_created_id
ON outbox_record (status, created_at, id)
INCLUDE (partition_no, next_retry_at, record_key);
CREATE INDEX idx_outbox_record_key_completed_created_id
ON outbox_record (record_key, completed_at, created_at, id);
CREATE INDEX idx_outbox_record_status_retry_partition
ON outbox_record (status, next_retry_at)
INCLUDE (partition_no);
CREATE INDEX idx_outbox_record_status_partition
ON outbox_record (status, partition_no);
For a maintenance window, run these statements through your migration tool with
writers stopped. For an online build, use CREATE INDEX CONCURRENTLY for each
statement and configure that migration to run outside a transaction. Inspect
and resolve any invalid indexes left by an interrupted concurrent build before
retrying; an existing name alone does not prove an index is usable.
Check the installed definitions:
SELECT indexname, indexdef
FROM pg_indexes
WHERE schemaname = current_schema()
AND tablename = 'outbox_record'
ORDER BY indexname;
Full MySQL schema · Full MariaDB schema
CREATE INDEX idx_outbox_record_status_created_id
ON outbox_record (status, created_at, id, partition_no, next_retry_at, record_key);
CREATE INDEX idx_outbox_record_key_completed_created_id
ON outbox_record (record_key, completed_at, created_at, id);
CREATE INDEX idx_outbox_record_status_retry_partition
ON outbox_record (status, next_retry_at, partition_no);
CREATE INDEX idx_outbox_record_status_partition
ON outbox_record (status, partition_no);
These definitions match the shipped InnoDB schemas. Use the indexes' full column definitions; prefix indexes are not equivalent. If your original table differs in column widths, character sets or storage options, check its index-size limits before applying the migration. Select online DDL options supported by your database version if writers must remain active.
SHOW INDEX FROM outbox_record;
H2 uses two record indexes:
CREATE INDEX idx_outbox_record_status_created_id
ON outbox_record (status, created_at, id);
CREATE INDEX idx_outbox_record_key_completed_created_id
ON outbox_record (record_key, completed_at, created_at, id);
For a persistent H2 database, preserve the existing database file and apply the migration before restarting the application.
SELECT INDEX_NAME, COLUMN_NAME, ORDINAL_POSITION
FROM INFORMATION_SCHEMA.INDEX_COLUMNS
WHERE TABLE_NAME = 'OUTBOX_RECORD'
ORDER BY INDEX_NAME, ORDINAL_POSITION;
Adjust identifier case if your application uses quoted or lowercase identifiers.
CREATE INDEX idx_outbox_record_status_created_id
ON outbox_record (status, created_at, id)
INCLUDE (partition_no, next_retry_at, record_key);
CREATE INDEX idx_outbox_record_key_completed_created_id
ON outbox_record (record_key, completed_at, created_at, id);
CREATE INDEX idx_outbox_record_status_retry_partition
ON outbox_record (status, next_retry_at)
INCLUDE (partition_no);
CREATE INDEX idx_outbox_record_status_partition
ON outbox_record (status, partition_no);
Use your actual schema, for example dbo.outbox_record, when qualifying the table.
Select online index-build options supported by your SQL Server installation if
writers must remain active.
SELECT i.name, c.name AS column_name, ic.key_ordinal, ic.is_included_column
FROM sys.indexes i
JOIN sys.index_columns ic
ON ic.object_id = i.object_id AND ic.index_id = i.index_id
JOIN sys.columns c
ON c.object_id = ic.object_id AND c.column_id = ic.column_id
WHERE i.object_id = OBJECT_ID('outbox_record')
ORDER BY i.name, ic.is_included_column, ic.key_ordinal, ic.index_column_id;
Oracle uses shorter index names and includes covering columns in the index key:
CREATE INDEX idx_outbox_rec_status_created
ON outbox_record (status, created_at, id, partition_no, next_retry_at, record_key)
COMPRESS 1;
CREATE INDEX idx_outbox_rec_k_c_c_id
ON outbox_record (record_key, completed_at, created_at, id)
COMPRESS 1;
CREATE INDEX idx_outbox_rec_s_r_p
ON outbox_record (status, next_retry_at, partition_no)
COMPRESS 1;
CREATE INDEX idx_outbox_rec_s_p
ON outbox_record (status, partition_no)
COMPRESS 2;
These are standalone DDL statements for an existing table. Do not copy the table-creation PL/SQL block from the fresh-install schema: that block creates the indexes only when it creates the table. Select appropriate online DDL options if writers must remain active.
SELECT index_name, column_name, column_position
FROM user_ind_columns
WHERE table_name = 'OUTBOX_RECORD'
ORDER BY index_name, column_position;
These migrations add record indexes only. Keep the existing primary keys, instance indexes and partition-assignment indexes.
Keep schema creation separate from migration
Configure the upgraded application to use your migration tool's schema:
namastack:
outbox:
jdbc:
schema-initialization:
enabled: false
On PostgreSQL, H2 and SQL Server, the initializer can add missing indexes to existing
tables at startup. MySQL/MariaDB define indexes inside CREATE TABLE IF NOT EXISTS,
and Oracle creates them inside the table-creation block, so running those creation
scripts again does not add the new indexes to an existing table. Explicit migrations
make the upgrade step visible and controllable on every database.
4. Deploy and verify
Rehearse on a database copy. For a rollout with a maintenance window:
- Back up the database, pause producers and gracefully stop the old instances.
- Apply the index migration and start 2.0.0 against the same database.
- Confirm that existing pending records and due retries reach their handlers and downstream systems, then resume producers.
- Check that new business writes and outbox records commit or roll back together.
Keep payload classes, handler IDs, serializer and retention settings unchanged during
this rollout. Keep processing-groups.enabled=false (the default) until every worker
has upgraded; adopt named groups separately. For rolling upgrades and rollback
requirements, follow Rolling Deployments.
Retain the old indexes through the rollback window.
Remove obsolete indexes after the rollout
Keep the old indexes while 1.x workers are active and during your rollback window. Once the rollout is verified, remove redundant old indexes in a separate migration to avoid their storage and write overhead. Confirm the actual names and definitions in your database first, especially if Hibernate or custom migrations created them.
| Default 1.11.1 JDBC index | Oracle equivalent |
|---|---|
idx_outbox_record_record_key_created | idx_outbox_rec_key_cr |
idx_outbox_record_partition_status_retry | idx_outbox_rec_p_s_r |
idx_outbox_record_status_retry | idx_outbox_rec_s_r |
idx_outbox_record_status | idx_outbox_rec_stat |
idx_outbox_record_record_key_completed_created | idx_outbox_rec_k_c_c |
The former JPA entity used idx_outbox_record_key_completed_created for the last
index. Your database can therefore have a different name even with otherwise
default configuration.
Drop only indexes that actually exist and have been superseded. The syntax is:
| Database | Drop syntax (replace old_index_name) |
|---|---|
| PostgreSQL / H2 / Oracle | DROP INDEX old_index_name; |
| MySQL / MariaDB / SQL Server | DROP INDEX old_index_name ON outbox_record; |
Do not drop your own application-specific indexes solely because they are absent from the new schema.
Other changes to check
| Change | Action, if relevant |
|---|---|
| Scheduling now rejects calls without an active Spring transaction. | No change for applications already scheduling transactionally. |
| Generated IDs and keys now use UUIDv7. | Accept both UUIDv4 and UUIDv7; existing IDs and string columns stay unchanged. |
| Equal creation timestamps are ordered by record ID. | Avoid relying on handler declaration order for timestamp ties. |
| Adaptive polling validates its intervals. | Use min-interval >= 1ms and max-interval >= min-interval. |
| Completed-record counts are disabled by default. | Opt in to COMPLETED or update affected dashboards and alerts; see record-status metrics. |
| State metrics are collected asynchronously. | Treat NaN as unknown, not zero; see Observability. |
| Adaptive polling evaluates each record key query relative to the keys it could return, and keeps its interval while an instance owns no partitions. | Review adaptive interval expectations; see Adaptive Polling. |
Custom extensions and tests
Only if you use repository APIs or construct Core objects directly
Rebuild these modules against 2.0.0 and update the affected APIs:
| Old API | Replacement |
|---|---|
OutboxRecordStatusRepository | OutboxRecordRepository |
save(record) | create(record) for new records; duplicate IDs must fail. |
update(record) | updateProcessingState(record); update only processing fields and return false for missing rows. |
findRecordKeysInPartitions(..., status, ...) | Remove the status argument; the query selects due NEW records. |
Java OutboxRecordMetadata constructor | Add trailing recordId and processingGroup arguments, e.g. null, "default" for scheduling fixtures. |
Java OutboxFailureContext constructor | Add trailing processingGroup, e.g. "default". |
OutboxPollingTrigger.onTaskComplete(recordCount) | onPollResult(found, requested); requested is the most keys the query could return. |
Custom repositories must also implement findIncompleteRecordPages,
findOldestCreatedAtByPartitions and findOldestDueNextRetryAtByPartitions.
Pages must include future NEW retries, preserve (createdAt, id) ordering, and
include an empty page for requested keys with no records. The oldest-due query must
match polling's eligibility rules. Follow the interface contracts when implementing
these methods. Kotlin metadata constructors provide defaults for the added fields.
Direct Java construction of messaging handlers also needs the new Boolean settings; see messaging constructors.