spring-projects / spring-statemachine

Spring Statemachine is a framework for application developers to use state machine concepts with Spring.
1.51k stars 598 forks source link

Make State Machine Mongo Collection Name (MongoDbRepositoryStateMachine) Configurable #1127

Open chinthakadd opened 7 months ago

chinthakadd commented 7 months ago

It seems that MongoDbRepositoryStateMachine Document Entity has a hard-coded collection name. This makes it difficult for consumers who has different collection naming conventions to make it configurable.

Can we provide SPEL/ Spring Configuration or Java Config based support to override the default collection names?

https://github.com/spring-projects/spring-statemachine/blob/1b2a868ab52d16646eea40071bc1ea8526cd9e0c/spring-statemachine-data/mongodb/src/main/java/org/springframework/statemachine/data/mongodb/MongoDbRepositoryStateMachine.java#L28

ZhongceXie commented 6 months ago

use case: since I created two state machines (order and transaction) in the same spring package, I think it's reasonable to store two state machines under the same DB with different collection names.

correct me if there is a better way to implement under such scenario.

chinthakadd commented 4 months ago

@ZhongceXie thank you for the comment. Yes that is a valid use-case IMO. In our case, our organization follows a standard convention of naming collection which differs from the MongoDbRepositoryStateMachine style naming. So we would like to have the flexibility to customize the name.