package cc.mrbird.febs.rabbit; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.DirectExchange; import org.springframework.amqp.core.Queue; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; import javax.annotation.Resource; /** * @author wzy * @date 2022-05-31 **/ @Configuration public class RabbitConfiguration { @Resource private ConnectionFactory connectionFactory; @Bean @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public RabbitTemplate rabbitTemplate() { return new RabbitTemplate(connectionFactory); } // === 业绩树 start === @Bean public DirectExchange achieveTreeExchange() { return new DirectExchange(QueueEnum.ACHIEVE_TREE.getExchange()); } @Bean public Queue achieveTreeQueue() { return new Queue(QueueEnum.ACHIEVE_TREE.getQueue()); } @Bean public Binding achieveTreeBind() { return BindingBuilder.bind(achieveTreeQueue()).to(achieveTreeExchange()).with(QueueEnum.ACHIEVE_TREE.getRoute()); } // === 业绩树 end === // === 提现手续费 start === @Bean public DirectExchange withdrawFeeExchange() { return new DirectExchange(QueueEnum.WITHDRAW_FEE.getExchange()); } @Bean public Queue withdrawFeeQueue() { return new Queue(QueueEnum.WITHDRAW_FEE.getQueue()); } @Bean public Binding withdrawFeeBind() { return BindingBuilder.bind(withdrawFeeQueue()).to(withdrawFeeExchange()).with(QueueEnum.WITHDRAW_FEE.getRoute()); } // === 提现手续费 end === // === tfc最新价 start === @Bean public DirectExchange tfcNewPriceExchange() { return new DirectExchange(QueueEnum.TFC_NEW_PRICE.getExchange()); } @Bean public Queue tfcNewPriceQueue() { return new Queue(QueueEnum.TFC_NEW_PRICE.getQueue()); } @Bean public Binding tfcNewPriceBind() { return BindingBuilder.bind(tfcNewPriceQueue()).to(tfcNewPriceExchange()).with(QueueEnum.TFC_NEW_PRICE.getRoute()); } // === tfc最新价 end === // === 手续费分发 start === @Bean public DirectExchange feeDistributeExchange() { return new DirectExchange(QueueEnum.DISTRIB_PROFIT.getExchange()); } @Bean public Queue feeDistributeQueue() { return new Queue(QueueEnum.DISTRIB_PROFIT.getQueue()); } @Bean public Binding feeDistributeBind() { return BindingBuilder.bind(feeDistributeQueue()).to(feeDistributeExchange()).with(QueueEnum.DISTRIB_PROFIT.getRoute()); } // === 手续费分发 end === }