Skip to main content
The MongoDB backend stores all SMP data in a MongoDB database as BSON documents. It is a good fit for organisations that already operate MongoDB infrastructure, or that prefer a schema-flexible document store.

Requirements

  • MongoDB 4.4 or later (tested with MongoDB 7.x). Replica set mode is recommended for write-concern guarantees.
  • MongoDB Java driver 5.6.3 (bundled with phoss-smp-backend-mongodb).

Selecting the MongoDB backend

Set the following property in application.properties:
smp.backend = mongodb
Use the phoss-smp-webapp-mongodb WAR when deploying.

Configuration

Only two properties are required:
mongodb.connectionstring = mongodb://localhost
mongodb.dbname           = phoss-smp
PropertyRequiredDescription
mongodb.connectionstringYesMongoDB connection string URI. Supports all URI options including authentication, TLS, and replica-set addresses.
mongodb.dbnameYesName of the MongoDB database to use. The database is created automatically if it does not exist.
If either mongodb.connectionstring or mongodb.dbname is missing, phoss SMP will throw an IllegalStateException and refuse to start.

Connection string examples

mongodb.connectionstring = mongodb://localhost
mongodb.dbname           = phoss-smp
For MongoDB Atlas, use an mongodb+srv:// URI. All connection options (TLS, authentication, read preference, write concern) are specified in the connection string; no additional properties are needed.

Collection structure

phoss SMP creates all collections automatically when first accessed. Writes use WriteConcern.MAJORITY with journaling enabled to guarantee durability.

SMP domain collections

CollectionContents
smp-servicegroupService groups (participants)
smp-serviceinfoService metadata and endpoint information
smp-redirectDocument-type redirects
smp-businesscardBusiness card data (Peppol Directory)
smp-transportprofileRegistered transport profiles
smp-smlinfoSML endpoint configuration
smp-settingsSMP runtime settings
smp-participant-migrationParticipant migration records

Security and system collections

CollectionContents
usersManagement UI user accounts
user-rolesRole definitions
user-groupsUser group assignments
user-tokensAPI bearer tokens
smp-sys-migrationInternal system migration history
smp-sys-messageSystem-wide messages shown in the UI
smp-long-running-jobBackground job results

Docker setup

The following compose.yml starts phoss SMP together with a standalone MongoDB instance:
services:
  mongo:
    image: mongo:7
    restart: unless-stopped
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: secret
    volumes:
      - mongo-data:/data/db
    ports:
      - "27017:27017"

  smp:
    image: phoss-smp-mongodb:latest
    restart: unless-stopped
    depends_on:
      - mongo
    environment:
      # Override properties via environment variables if supported by your image
      MONGODB_CONNECTIONSTRING: "mongodb://root:secret@mongo:27017/?authSource=admin"
      MONGODB_DBNAME: phoss-smp
    ports:
      - "8080:8080"

volumes:
  mongo-data:
Always persist the MongoDB data directory (/data/db) with a named volume or bind mount. Containers without a volume will lose all data on restart.

Migration from the XML backend

When phoss SMP first starts with the MongoDB backend, it automatically migrates ph-oton security data (users, roles, user groups, user tokens) from the XML files in webapp.datapath if the corresponding MongoDB collections are empty. After a successful migration the original XML files are renamed with a .migrated suffix. SMP-specific data (service groups, redirects, service metadata, business cards) is not migrated automatically. Re-register this data via the management UI or REST API after switching backends.

Advantages

  • Schema flexibility. Documents can evolve independently of a fixed table schema.
  • Horizontal scaling. MongoDB replica sets and sharding enable high-availability and read scaling.
  • MongoDB Atlas support. Use a fully managed cloud MongoDB cluster with no infrastructure to operate.
  • Automatic collection creation. No DDL scripts or schema setup steps are required; collections are created on first use.

Limitations

  • Requires an externally managed MongoDB server (or Atlas cluster).
  • No Flyway-style versioned migrations; schema changes between phoss SMP versions are handled via internal one-time migrations.
  • MongoDB replica set mode is required to take advantage of WriteConcern.MAJORITY durability guarantees. A standalone MongoDB instance downgrades to weaker write guarantees.

Build docs developers (and LLMs) love