26 lines
861 B
Java
26 lines
861 B
Java
package com.yupi.springbootinit.config;
|
||
|
||
import org.springframework.amqp.core.Queue;
|
||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||
import org.springframework.amqp.support.converter.MessageConverter;
|
||
import org.springframework.context.annotation.Bean;
|
||
import org.springframework.context.annotation.Configuration;
|
||
|
||
@Configuration
|
||
public class RabbitMQConfig {
|
||
private static final String QUEUE = "HOST_INFO_QUEUE";
|
||
|
||
//创建队列
|
||
//true:表示持久化
|
||
//队列在默认情况下放到内存,rabbitmq重启后就丢失了,如果希望重启后,队列
|
||
//数据还能使用,就需要持久化
|
||
@Bean
|
||
public Queue hostInfoQueue(){
|
||
return new Queue(QUEUE,true);
|
||
}
|
||
@Bean
|
||
public MessageConverter messageConverter(){
|
||
return new Jackson2JsonMessageConverter();
|
||
}
|
||
|
||
} |