|
@@ -2,7 +2,14 @@ package com.abi.qms.platform.infrastructure.config;
|
|
|
|
|
|
import com.abi.qms.platform.infrastructure.mq.TableStoreBatchInsertConsumer;
|
|
|
import com.abi.qms.platform.infrastructure.mq.TableStoreBatchUpdateConsumer;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.amqp.core.Message;
|
|
|
import org.springframework.amqp.core.Queue;
|
|
|
+import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
|
|
+import org.springframework.amqp.rabbit.connection.CorrelationData;
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
+import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
@@ -13,6 +20,7 @@ import org.springframework.context.annotation.Configuration;
|
|
|
* @date: 2021-05-11
|
|
|
*/
|
|
|
@Configuration
|
|
|
+@Slf4j
|
|
|
public class RabbitmqConfig {
|
|
|
|
|
|
@Bean(name = "qms_table_store_queue")
|
|
@@ -25,4 +33,19 @@ public class RabbitmqConfig {
|
|
|
return new Queue(TableStoreBatchUpdateConsumer.TABLE_STORE_BATCH_UPDATE_QUEUE);
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CachingConnectionFactory factory;
|
|
|
+
|
|
|
+ @Bean(name = "qmsRabbitTemplate")
|
|
|
+ public RabbitTemplate rabbitTemplate(){
|
|
|
+ RabbitTemplate template = new RabbitTemplate(factory);
|
|
|
+ template.setMessageConverter(new Jackson2JsonMessageConverter());
|
|
|
+ template.setMandatory(true);
|
|
|
+ template.setConfirmCallback((CorrelationData correlationData, boolean ack, String cause) ->
|
|
|
+ log.info("CorrelationData:{}, ack:{}, cause:{}", correlationData, ack, cause));
|
|
|
+ template.setReturnCallback((Message message, int replyCode, String replyText, String exchange, String routingKey) ->
|
|
|
+ log.info("message:{}, replyCode:{}, replyText:{}, exchange:{}, routingKey:{}", message, replyCode, replyText, exchange, routingKey));
|
|
|
+ return template;
|
|
|
+ }
|
|
|
+
|
|
|
}
|