| | |
| | | import org.springframework.amqp.core.BindingBuilder; |
| | | import org.springframework.amqp.core.DirectExchange; |
| | | import org.springframework.amqp.core.Queue; |
| | | import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; |
| | | import org.springframework.amqp.rabbit.connection.ConnectionFactory; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.beans.factory.config.ConfigurableBeanFactory; |
| | | import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.Scope; |
| | |
| | | |
| | | public static final String ROUTING_KEY_USDT_UPDATE = "routing_key_usdt_update"; |
| | | |
| | | public static final String EXCHANGE_USDT_ADDRESS = "exchange_usdt_address"; |
| | | |
| | | public static final String QUEUE_USDT_ADDRESS= "queue_usdt_address"; |
| | | |
| | | public static final String ROUTING_KEY_USDT_ADDRESS = "routing_key_usdt_address"; |
| | | |
| | | |
| | | public static final String EXCHANGE_FISH_HIT = "EXCHANGE_FISH_HIT"; |
| | | |
| | | public static final String QUEUE_FISH_HIT = "QUEUE_FISH_HIT"; |
| | | |
| | | public static final String ROUTING_KEY_FISH_HIT = "ROUTING_KEY_FISH_HIT"; |
| | | |
| | | /** |
| | | * 撮合交易 |
| | |
| | | |
| | | public static final String ROUTING_KEY_ROC_ORDER_SUBMIT = "roc-order-routingKey-submit"; |
| | | |
| | | public static final String EXCHANGE_ROC_ORDER_CANCEL = "roc-exchange-order-cancel"; |
| | | |
| | | public static final String QUEUE_ROC_ORDER_CANCEL = "roc-order-queue-cancel"; |
| | | |
| | | public static final String ROUTING_KEY_ROC_ORDER_CANCEL = "roc-order-routingKey-cancel"; |
| | | |
| | | public static final String EXCHANGE_ROC_ORDER_COMPLETE = "roc-exchange-order-complete"; |
| | | |
| | | public static final String QUEUE_ROC_ORDER_COMPLETE = "roc-order-queue-complete"; |
| | | |
| | | public static final String ROUTING_KEY_ROC_ORDER_COMPLETE = "roc-order-routingKey-complete"; |
| | | |
| | | public static final String QUEUE_TRC20_BLOCK = "QUEUE_TRC20_BLOCK"; |
| | | public static final String ROUTING_TRC20_BLOCK = "ROUTING_TRC20_BLOCK"; |
| | | |
| | | @Resource |
| | | private ConnectionFactory connectionFactory; |
| | |
| | | // connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED); |
| | | // return connectionFactory; |
| | | // } |
| | | |
| | | @Bean("customContainerFactory") |
| | | public SimpleRabbitListenerContainerFactory containerFactory(SimpleRabbitListenerContainerFactoryConfigurer configurer, |
| | | ConnectionFactory connectionFactory) { |
| | | SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); |
| | | factory.setConcurrentConsumers(10); |
| | | factory.setMaxConcurrentConsumers(10); |
| | | configurer.configure(factory, connectionFactory); |
| | | return factory; |
| | | } |
| | | |
| | | @Bean |
| | | @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) |
| | |
| | | return BindingBuilder.bind(ordereSubmitQueue()).to(orderSubmitExchange()).with(ROUTING_KEY_ROC_ORDER_SUBMIT); |
| | | } |
| | | |
| | | // 交易订单 |
| | | @Bean |
| | | public DirectExchange orderCancelExchange() { |
| | | return new DirectExchange(EXCHANGE_ROC_ORDER_CANCEL); |
| | | } |
| | | |
| | | |
| | | @Bean |
| | | public Queue ordereCancelQueue() { |
| | | return new Queue(QUEUE_ROC_ORDER_CANCEL, true); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding bindingCancelOrder() { |
| | | return BindingBuilder.bind(ordereCancelQueue()).to(orderCancelExchange()).with(ROUTING_KEY_ROC_ORDER_CANCEL); |
| | | } |
| | | // 交易订单 |
| | | @Bean |
| | | public DirectExchange orderCompleteExchange() { |
| | | return new DirectExchange(EXCHANGE_ROC_ORDER_COMPLETE); |
| | | } |
| | | |
| | | |
| | | @Bean |
| | | public Queue ordereCompleteQueue() { |
| | | return new Queue(QUEUE_ROC_ORDER_COMPLETE, true); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding bindingCompleteOrder() { |
| | | return BindingBuilder.bind(ordereCompleteQueue()).to(orderCompleteExchange()).with(ROUTING_KEY_ROC_ORDER_COMPLETE); |
| | | } |
| | | |
| | | |
| | | @Bean |
| | | public DirectExchange usdtUpdateExchange() { |
| | |
| | | return BindingBuilder.bind(usdtUpdateQueue()).to(usdtUpdateExchange()).with(ROUTING_KEY_USDT_UPDATE); |
| | | } |
| | | |
| | | @Bean |
| | | public DirectExchange fishHitExchange() { |
| | | return new DirectExchange(EXCHANGE_FISH_HIT); |
| | | } |
| | | |
| | | |
| | | @Bean |
| | | public Queue fishHitQueue() { |
| | | return new Queue(QUEUE_FISH_HIT, true); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding fishHitbinding() { |
| | | return BindingBuilder.bind(fishHitQueue()).to(fishHitExchange()).with(ROUTING_KEY_FISH_HIT); |
| | | } |
| | | |
| | | @Bean |
| | | public DirectExchange usdtAddressExchange() { |
| | | return new DirectExchange(EXCHANGE_USDT_ADDRESS); |
| | | } |
| | | |
| | | |
| | | @Bean |
| | | public Queue usdtAddressQueue() { |
| | | return new Queue(QUEUE_USDT_ADDRESS, true); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding usdtAddressbinding() { |
| | | return BindingBuilder.bind(usdtAddressQueue()).to(usdtAddressExchange()).with(ROUTING_KEY_USDT_ADDRESS); |
| | | } |
| | | |
| | | @Bean |
| | | public Queue trc20Queue() { |
| | | return new Queue(QUEUE_TRC20_BLOCK); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding trc20Binding() { |
| | | return BindingBuilder.bind(trc20Queue()).to(defaultExchange()).with(ROUTING_TRC20_BLOCK); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 交换器A 可以继续添加交换器B C |