Comments (8)
@tetrade ,
thank you for the report!
I'd be happy to fix the problem, but I don't understand how to read that object tree.
Yes, I do see RabbitMessageFuture
and its TimeoutTask
reference. But it is not clear for me what is requestMessage
and why that RabbitMessageFuture
is a part of it?
Any chances to determine what you are doing in your code with this AsyncRabbitTemplate
?
from spring-amqp.
@artembilan
requestMessage
- name of field in RabbitFuture
. I guess that TimeoutTask in some reason didn't deleted from memory and still have reference from Scheldued that created here org.springframework.amqp.rabbit.AsyncRabbitTemplate#timeoutTask
from spring-amqp.
In short, I just use Rabbit to send a photo to a third-party service for processing and wait for a response via Direct Reply-to. When all the Future (many photos have been analyzed) are completed, I consider the project processed and upload everything to the user.
I initially thought that I was mistaken, because I have an internal ConcurrentMap in my code that takes into account the Id of the photo and stores it as the value of RabbitFuture so that when re-requesting it, I understand where to wait for a response.
However, given my implementation, there is hardly a leak there. And the profiler shows that there is a leak in scheduled tasks in Java
from spring-amqp.
As you see the logic there is like this:
@Nullable
private ScheduledFuture<?> timeoutTask(RabbitFuture<?> future) {
if (this.receiveTimeout > 0) {
this.lock.lock();
try {
if (!this.running) {
this.pending.remove(future.getCorrelationId());
throw new IllegalStateException("'AsyncRabbitTemplate' must be started.");
}
return this.taskScheduler.schedule(
new TimeoutTask(future, this.pending, this.directReplyToContainer),
Instant.now().plusMillis(this.receiveTimeout));
}
finally {
this.lock.unlock();
}
}
return null;
}
So, such a timeout task is scheduled to be executed after that this.receiveTimeout
(30 seconds
by default).
Let's see if the problem with that ThreadPoolTaskScheduler
with the default as private volatile int poolSize = 1;
!
This way, it feels like "too many messages" would cause such a pool to be exhausted and therefore we see some kind of memory leak for some period of time until the queue of those TimeoutTask
is cleared.
You can set an external ThreadPoolTaskScheduler
with a bigger thread pool to mitigate workload.
Again: this is just an assumption since I don't see how else those TimeoutTask
instances could be held in the memory if scheduling is done properly.
from spring-amqp.
Related Issues (20)
- Document that micrometer observations aren't started for batch listeners HOT 4
- Unable to access AMQP Channel from RabbitListenerErrorHandler in case of MessageConversionException HOT 1
- Deadlock when reaching channel limit in DirectMessageListenerContainer HOT 5
- Remove deprecated method in the `RabbitListenerErrorHandler` HOT 1
- DefaultMessagePropertiesConverter#toMessageProperties should handle x-delay in Short HOT 4
- DefaultMessagePropertiesConverter#toMessageProperties should handle x-delay in Short HOT 1
- Memory leak with AsyncRabbitTemplate HOT 5
- Memory leak with AsyncRabbitTemplate HOT 1
- Use JDK `ObjectInputFilter` instead of calling `AllowedListDeserializingMessageConverter::checkAllowedList` in `ConfigurableObjectInputStream::resolveClass` HOT 2
- Fix RabbitMQ x-death header documentation HOT 8
- BatchingRabbitTemplate Overwrites Custom Headers of Batched Messages HOT 2
- Mitigate channel leak in the `CachingConnectionFactory` when connection is closed from the broker HOT 2
- Mitigate channel leak in the `CachingConnectionFactory` when connection is closed from the broker HOT 1
- AbstractAdaptableMessageListener throws NPE when basicAck with async @RabbitListener and batch consumer HOT 1
- Fix `RabbitFuture` for interrupted thread
- Fix `RabbitFuture` for interrupted thread HOT 1
- Resolve deprecations for the `RabbitListenerErrorHandler` HOT 1
- Add Support for `x-consistent-hash` HOT 3
- ShutdownSignalException when sending message to RabbitMQ after app restart/launch for the first time HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-amqp.