| | |
| | | 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_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"; |
| | | |
| | | /** |
| | | * 撮合交易 |
| | |
| | | // 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) |
| | | public RabbitTemplate rabbitTemplate() { |
| | |
| | | } |
| | | |
| | | @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); |
| | | } |