@ 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: