mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善rabbitmq配置
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
package cn.lihongjie.coal.rabbitmq;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.springframework.amqp.core.*;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitTemplateCustomizer;
|
||||
import org.springframework.boot.convert.DurationStyle;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -27,6 +32,14 @@ public class RabbitMQConfiguration {
|
||||
|
||||
public static final Long[] DELAY_QUEUES_TIME = Arrays.stream(DELAY_QUEUES).map(x -> DurationStyle.detectAndParse(x).toMillis()).toArray(Long[]::new);
|
||||
|
||||
@Autowired private ObjectMapper objectMapper;
|
||||
|
||||
@Bean
|
||||
RabbitTemplateCustomizer rabbitTemplateCustomizer() {
|
||||
return template -> {
|
||||
template.setMessageConverter(new Jackson2JsonMessageConverter(objectMapper));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
|
||||
Reference in New Issue
Block a user