package com.red.circle.mq.rocket.business.config;

import com.red.circle.component.mq.MessageEventProcess;
import com.red.circle.component.redis.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Slf4j
@Profile("local")
@Configuration
@ConditionalOnProperty(name = "rocketmq.local-disable", havingValue = "true")
public class SharedLocalRocketMqFallbackConfiguration {

  @Bean
  @ConditionalOnMissingBean(MessageEventProcess.class)
  public MessageEventProcess messageEventProcess(RedisService redisService) {
    log.warn("rocketmq.local-disable=true, register shared local MessageEventProcess fallback");
    return new MessageEventProcess(redisService);
  }
}
