主页 > 创业  > 

智能图像处理平台:RabbitMQ配置

智能图像处理平台:RabbitMQ配置

前面我们用Docker拉了rabbitMQ,并集成进了springboot,现在我们先写配置类:

package com.llpp.config; import com.llpp.service.impl.ImageServiceImpl; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.Queue; import org.springframework.amqp.core.TopicExchange; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class RabbitMQConfig { public static final String EXCHANGE_NAME = "image_processing_exchange"; public static final String QUEUE_NAME = "image_processing_queue"; public static final String ROUTING_KEY = "image.processing"; @Autowired private ConnectionFactory connectionFactory; @Bean public TopicExchange exchange() { return new TopicExchange(EXCHANGE_NAME); } @Bean public Queue queue() { return new Queue(QUEUE_NAME, true); } @Bean public Binding binding(Queue queue, TopicExchange exchange) { return BindingBuilder.bind(queue).to(exchange).with(ROUTING_KEY); } @Bean public SimpleMessageListenerContainer messageListenerContainer() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setQueueNames(QUEUE_NAME); container.setMessageListener(new MessageListenerAdapter(new ImageServiceImpl())); return container; } }

标签:

智能图像处理平台:RabbitMQ配置由讯客互联创业栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“智能图像处理平台:RabbitMQ配置