I am trying to test the behavior spring rabbitmq confirm callback , As per the api description if any negative acknowledgment is sent through consumer, confirm callback should gives the false value of ack but in my case always gives true. Even i published the message to deleted queue , i got the true value in confirm callback . Please let me know how to get the negative acknowledgement.
Below is the code how i created the RabbitTemplate bean.
@Bean
public RabbitTemplate rabbitTemplate( ConnectionFactory connectionFactory ) {
RabbitTemplate rabbitTemplate = new RabbitTemplate( connectionFactory );
((CachingConnectionFactory)rabbitTemplate.getConnectionFactory()).setPublisherConfirms( true );
rabbitTemplate.setConfirmCallback( new ConfirmCallback() {
@Override
public void confirm( CorrelationData corData, boolean ack, String cause ) {
System.out.println( "devconfig.rabbitTemplate(...).new ConfirmCallback() {...}.confirm()"+corData );
System.out.println( "devconfig.rabbitTemplate(...).new ConfirmCallback() {...}.confirm()"+ack );
}
} );
return rabbitTemplate;
}