Home > Back-end >  The RabbitMq SpringBoot 2.2.7 configuration problems
The RabbitMq SpringBoot 2.2.7 configuration problems

Time:12-22

The following is my rabbitmq configuration code

 
@ Slf4j
@ Configuration
Public class RabbitConfig {

The @autowired
Private RabbitTemplate RabbitTemplate;

/* *
* define the rabbitMq serialized as JSON
*
* @ return Jackson2JsonMessageConverter
*/
@ Bean
Public MessageConverter MessageConverter () {
Return new Jackson2JsonMessageConverter ();
}

/* *
* custom rabbitMqTemplate
*/
@ PostConstruct
Public void initRabbitTemplate () {
//messages are received callback
RabbitTemplate. SetConfirmCallback (new rabbitTemplate. ConfirmCallback () {
@ Override
Public void confirm (CorrelationData CorrelationData, Boolean ack, String cause) {
The info (" news confirmed: "+ ack);
}
});
}
}


The key is configured MessageConverter here, as long as the configuration of the, in any other place to use
The @autowired
Private RabbitTemplate RabbitTemplate;

An


Error, help!!!!!

CodePudding user response:

 


The @autowired
Private RabbitTemplate RabbitTemplate;

/* *
* custom rabbitMqTemplate
*/
@ PostConstruct
Public void initRabbitTemplate () {
//messages are received callback
RabbitTemplate. SetConfirmCallback (new rabbitTemplate. ConfirmCallback () {
@ Override
Public void confirm (CorrelationData CorrelationData, Boolean ack, String cause) {
The info (" news confirmed: "+ ack);
}
});
}


Found the reason, it is the problem here, but, I want to use the custom callback requires, and now what should I do

CodePudding user response:

references from entry to the 1/f, begging response:
 


The @autowired
Private RabbitTemplate RabbitTemplate;

/* *
* custom rabbitMqTemplate
*/
@ PostConstruct
Public void initRabbitTemplate () {
//messages are received callback
RabbitTemplate. SetConfirmCallback (new rabbitTemplate. ConfirmCallback () {
@ Override
Public void confirm (CorrelationData CorrelationData, Boolean ack, String cause) {
The info (" news confirmed: "+ ack);
}
});
}


Found the reason, it is the problem here, but, I want to use the custom callback requires, now what


Has been solved, can't write a class, I also don't know why, the pit!
  • Related