📜  axon mongodb 配置 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:23.458000             🧑  作者: Mango

代码示例1
// omitting the other imports just to have a smaller code block
import com.mongodb.client.MongoClient

    /**
     * Configures Mongo as the Storage Engine.
     */
    @Bean
    fun storageEngine(client: MongoClient) = MongoEventStorageEngine.builder()
        .mongoTemplate(
            DefaultMongoTemplate.builder()
                .mongoDatabase(client)
                .build()
        )
        .build()

    /**
     * Configures to use Mongo embedded event store.
     */
    @Bean
    fun eventStore(storageEngine: EventStorageEngine) = EmbeddedEventStore.builder().storageEngine(storageEngine).build()

    /**
     * Configures to use in-memory token store.
     */
    @Bean
    fun tokenStore(client: MongoClient, serializer: Serializer) = MongoTokenStore.builder()
        .mongoTemplate(
            DefaultMongoTemplate.builder()
                .mongoDatabase(client)
                .build()
        )
        .serializer(serializer)
        .build()