de.otto.synapse.configuration.aws.CompactionAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of synapse-aws Show documentation
Show all versions of synapse-aws Show documentation
A library used at otto.de to implement Spring Boot based event-sourcing microserivces.
package de.otto.synapse.configuration.aws;
import de.otto.synapse.compaction.aws.CompactionService;
import de.otto.synapse.compaction.aws.SnapshotWriteService;
import de.otto.synapse.endpoint.receiver.MessageLogReceiverEndpointFactory;
import de.otto.synapse.eventsource.EventSourceBuilder;
import de.otto.synapse.state.ConcurrentHashMapStateRepository;
import de.otto.synapse.state.StateRepository;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(CompactionProperties.class)
@ImportAutoConfiguration(S3SnapshotAutoConfiguration.class)
public class CompactionAutoConfiguration {
@Bean
@ConditionalOnMissingBean(name = "compactionStateRepository")
public StateRepository compactionStateRepository() {
return new ConcurrentHashMapStateRepository<>();
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "synapse.compaction", name = "enabled", havingValue = "true")
public CompactionService compactionService(final SnapshotWriteService snapshotWriteService,
final StateRepository compactionStateRepository,
final EventSourceBuilder eventSourceBuilder,
final MessageLogReceiverEndpointFactory messageLogReceiverEndpointFactory) {
return new CompactionService(snapshotWriteService, compactionStateRepository, eventSourceBuilder, messageLogReceiverEndpointFactory);
}
}