io.naraplatform.daysman.daysboy.config.DaysboyRemoteServerConfig Maven / Gradle / Ivy
package io.naraplatform.daysman.daysboy.config;
import io.naraplatform.daysman.daysboy.config.condition.DaysboyRemoteCondition;
import io.naraplatform.daysman.daysboy.config.properties.DaysboyConfigProperties;
import io.naraplatform.daysman.daysboy.event.ApplicationContextUtils;
import io.naraplatform.daysman.daysboy.event.EventSubscriber;
import io.naraplatform.daysman.daysboy.mode.remote.EventStreamRemoteClient;
import io.naraplatform.daysman.daysboy.mode.remote.EventSubscriptionRemoteClient;
import io.naraplatform.daysman.daysboy.mode.remote.consumer.DaysmanConsumer;
import io.naraplatform.daysman.daysboy.mode.remote.listener.TransactionListenerForClient;
import io.naraplatform.daysman.daysboy.mode.remote.worker.InitRequester;
import io.naraplatform.daysman.daysboy.store.LocalStreamEventStore;
import io.naraplatform.daysman.mediator.spec.EventStreamService;
import io.naraplatform.daysman.mediator.spec.EventSubscriptionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import javax.annotation.PostConstruct;
@Configuration
@Conditional(DaysboyRemoteCondition.class)
@EnableConfigurationProperties({DaysboyConfigProperties.class})
@Import({TransactionListenerForClient.class, DaysmanConsumer.class, EventSubscriber.class, ApplicationContextUtils.class})
@Slf4j
public class DaysboyRemoteServerConfig implements DaysboyConfig {
//
private final DaysboyConfigProperties properties;
private final DaysmanConsumer daysmanConsumer;
private final LocalStreamEventStore localStreamEventStore;
private final ApplicationEventPublisher applicationEventPublisher;
public DaysboyRemoteServerConfig(DaysboyConfigProperties properties, DaysmanConsumer daysmanConsumer,
LocalStreamEventStore localStreamEventStore, ApplicationEventPublisher applicationEventPublisher) {
//
this.properties = properties;
this.daysmanConsumer = daysmanConsumer;
this.localStreamEventStore = localStreamEventStore;
this.applicationEventPublisher = applicationEventPublisher;
}
@PostConstruct
public void initialize() {
//
log.info("Initialize daysman-client(MODE:remote)...");
new InitRequester(eventSubscriptionService(), properties).start();
}
@Bean
@Override
public EventSubscriptionService eventSubscriptionService() {
//
log.info("create EventSubscriptionDaysmanClient... host:{}, port:{}", properties.getServiceHost(), properties.getServicePort());
return new EventSubscriptionRemoteClient(properties.getServiceHost(), properties.getServicePort());
}
@Bean
@Override
public EventStreamService eventStreamService() {
//
log.info("create EventStreamDaysmanClient...");
return new EventStreamRemoteClient(daysmanConsumer, localStreamEventStore, applicationEventPublisher);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy