Memory leak with AsyncRabbitTemplate
tetrade opened this issue · 5 comments
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;
}
I’m on sick day off, so if you have an idea how to fix, feel free to contribute it then! I’ll be happy to review when I’m back.
Thanks
I’m on sick day off, so if you have an idea how to fix, feel free to contribute it then! I’ll be happy to review when I’m back.
Thanks
I wish you a speedy recovery ! Okay I will try to fix it :)
Hi @tetrade !
I'm back from leave and ready to tackle this.
Let me know if you have started looking into this, so we don't cross each other.
We have a release next Monday if that matters somehow...
Thanks
So, apparently the test and fix are simple, so I decided to go ahead and do it myself.
Feel free to contribute anything else!
Yeah ! I just study and don't see your message :) Next time you will see my contribution 👍
Good resolve of the bug