
package com.tmerclub.cloud.product.config;

import com.tmerclub.cloud.common.rocketmq.config.RocketMqAdapter;
import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * @author tmerclub
 * @date 2021/3/30
 */
@RefreshScope
@Configuration
public class RocketMqConfig {

    @Autowired
    private RocketMqAdapter rocketMqAdapter;

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate stockBillLogTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.STOCK_BILL_LOG_TOPIC);
    }

//    @Lazy
//    @Bean(destroyMethod = "destroy")
//    public RocketMQTemplate stockBillLogPurchaseStorageTemplate() {
//        return rocketMqAdapter.getTransactionTemplateByTopicName(RocketMqConstant.STOCK_BILL_LOG_PURCHASE_STORAGE_TOPIC);
//    }

}
