Skip to content

Conversation

@geso02
Copy link
Contributor

@geso02 geso02 commented Oct 1, 2025

Description:

This MR introduces configurable properties for MongoDB collection names in the AAS Registry and Submodel Registry.
Previously, collection names were hardcoded via @document annotations. These have been replaced by configurable properties, allowing users to override them in application.yaml while still defaulting to the existing names.

Changes:

Added configuration properties:

basyx.aasregistry.mongodb.collectionName (default: aasdescriptors)

basyx.submodelregistry.mongodb.collectionName (default: submodeldescriptors)

Updated storage implementations to resolve collection names via configuration

Removed static @document annotations to avoid conflicts

Retained @id annotations for proper _id mapping in MongoDB

Adjusted Lombok configuration to ensure builds succeed with newer Java versions via Maven

Why:

Gives users flexibility to customize collection names for different environments or deployments, and improves build compatibility with modern Java versions.

Issue:

Closes #873

…ries

- Introduced properties:
  - basyx.aasregistry.mongodb.collectionName (default: aasdescriptors)
  - basyx.submodelregistry.mongodb.collectionName (default: submodeldescriptors)
- Removed @document annotations to avoid static collection binding
- Preserved @id usage for MongoDB _id mapping

refs eclipse-basyx#873
@aaronzi aaronzi merged commit 87d97dd into eclipse-basyx:main Oct 1, 2025
52 of 54 checks passed
@Log4j2
public class MongoDbConfiguration {

@Value("${basyx.aasregistry.mongodb.collectionName:submodeldescriptors}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaronzi Should'nt it be aasdescriptors at this point? See #900

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

@geso02
Copy link
Contributor Author

geso02 commented Oct 29, 2025

Quick thought: Changing the default collection name could be a breaking change for existing deployments - they'd lose access to their data after upgrading since the app would look for a different collection.
Maybe it's better to keep the old default for backward compatibility? Users who want the new name can still configure it via the property. The configurability is already there, so new deployments can easily use better naming.

@aaronzi
Copy link
Member

aaronzi commented Oct 29, 2025

It would be a breaking change if we had a full release of BaSyx Java (which is not the case). But you are right, this could potentially cause issues when the next milestone is released or if somebody deploys the snapshots. But having a semantically incorrect collection name is also not really helpful. Maybe it would be enough to inform users about this change once a release is published. This way they can just apply the necessary setting and won't loose their data

@seicke
Copy link
Member

seicke commented Oct 31, 2025

@aaronzi / @geso02

How to specify/set up a self-chosen MongoDB collection name, e.g. for the BaSyx AAS Registry using environment variables in a docker compose file?

I assumed it should be working with environment variable SPRINT_DATA_MONGODB_COLLECTIONNAME

...
  basyx-aas-registry-dev:
    image: eclipsebasyx/aas-registry-log-mongodb:2.0.0-SNAPSHOT
    environment:
      SERVER_SERVLET_CONTEXT_PATH: /
      BASYX_CORS_ALLOWED_ORIGINS: '*'
      BASYX_CORS_ALLOWED_METHODS: GET,POST,PATCH,DELETE,PUT,OPTIONS,HEAD
      BASYX_FEATURE_AUTHORIZATION_ENABLED: true
      BASYX_FEATURE_AUTHORIZATION_TYPE: rbac
      BASYX_FEATURE_AUTHORIZATION_JWTBEARERTOKENPROVIDER: keycloak
      BASYX_FEATURE_AUTHORIZATION_RBAC_FILE: file:/workspace/config/rbac_rules.json
      SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: http://${KEYCLOAK_HOST}:${KEYCLOAK_PORT}/realms/${KEYCLOAK_REALM}
      SPRING_DATA_MONGODB_URI: mongodb://${MONGO_ADMIN}:${MONGO_ADMIN_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}
      SPRING_DATA_MONGODB_DATABASE: aas-registry
      SPRINT_DATA_MONGODB_COLLECTIONNAME: aasdescriptorstest
    volumes:
      - ./conf/basyx/aas-registry/basyx_aas_registry_rbac_rules.json:/workspace/config/rbac_rules.json
    ports:
      - ${BASYX_AAS_REGISTRY_PORT_PUBLISHED}:${BASYX_AAS_REGISTRY_PORT}
...

so that the collection name aasdescriptorstest instead of the default aasdescriptors is used. But it seems not working, after docker compose up the default collection name is still used:
2025-10-31 11_29_06-basyx-aas-web-ui (Workspace) -  tmp

@aaronzi
Copy link
Member

aaronzi commented Oct 31, 2025

You got a typo there @seicke . It's SPRING and not SPRINT

@seicke
Copy link
Member

seicke commented Oct 31, 2025

@aaronzi You are absoluty right, sorry for that!

However, even with SPRING_DATA_MONGODB_COLLECTIONNAME: aasdescriptorstest the collection is named aasdescriptors (default collection name)

@seicke
Copy link
Member

seicke commented Nov 1, 2025

It has to be BASYX_AASREGISTRY_MONGODB_COLLECTIONNAME: aasdescriptorstest instead of SPRING_DATA_MONGODB_COLLECTIONNAME: aasdescriptorstest

@aaronzi
Copy link
Member

aaronzi commented Nov 3, 2025

Yes, you are right. I missed that but it's clear from the code in this PR

@aaronzi
Copy link
Member

aaronzi commented Nov 17, 2025

Quick thought: Changing the default collection name could be a breaking change for existing deployments - they'd lose access to their data after upgrading since the app would look for a different collection. Maybe it's better to keep the old default for backward compatibility? Users who want the new name can still configure it via the property. The configurability is already there, so new deployments can easily use better naming.

So what I have done now is I reverted both the default submodel registry collection name (to submodelDescriptor) and the default aas registry collection name (to assetAdministrationShellDescriptor). Now there should be no breaking changes anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Custom MongoDB Collection Names in Registry Components (BaSyx Java SDK v2)

3 participants