Closed
Description
3.0.10
When i use org.springframework.amqp.rabbit.AsyncRabbitTemplate#sendAndReceive(java.lang.String, org.springframework.amqp.core.Message)
and when get reply, nothing is clearing or canceling org.springframework.amqp.rabbit.RabbitFuture#timeoutTask
and for every sending (if i get answer) i got memory leak , as shown in the photo (find this every time with profiler)
I got bug with this snippet of code:
Message message = MessageBuilder
.withBody(mapper.writeValueAsBytes(photoMapper.mapToCkSendProcessDto(imageModel)))
.setContentType(MessageProperties.CONTENT_TYPE_JSON).build();
log.debug("Send image {} to process", imageModel.getId());
return asyncRabbitTemplate.sendAndReceive(queue.getActualName(), message)
.thenApply(mes -> {
log.debug("Get image {} after process", imageModel.getId());
try {
// ..........
} catch (IOException e) {
throw new RuntimeException(e);
}
}).handle((el, err) -> err == null ? el : null);
@Bean
public ConnectionFactory rabbitConnectionFactory(com.rabbitmq.client.ConnectionFactory cf) {
return new CachingConnectionFactory(cf);
}
@Bean
public RabbitTemplate template(ConnectionFactory connectionFactory) {
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
return rabbitTemplate;
}
@Bean
public AsyncRabbitTemplate asyncRabbitTemplate(RabbitTemplate template) {
AsyncRabbitTemplate asyncRabbitTemplate = new AsyncRabbitTemplate(template);
asyncRabbitTemplate.setReceiveTimeout(6000000);
return asyncRabbitTemplate;
}